Join the Soledad Facebook Users Group here
for Share, assistance, discussion, and Updates related to Soledad WordPress Theme.

If you can't create a new ticket - you can send us an email via our contact form and we will get back to you.

Okay
  Public Ticket #2350240
Defer Loading the JS of Penci Facebook and Youtube
Closed

Comments

  • upsangel started the conversation

    Hi sir,

    I am trying to optimize the speed of the site. Currently the major concern is the JavaScript from the Facebook and YouTube plugin, both of them seems cannot be optimized (defer/async) by the Autopmize JavaScript plugin, do you have idea how to defer/async the JS induced by Penci Facebook and Youtube?

    Thank you very much for your kind help!

  •  2,699
    PenciDesign replied

    Hi,

    You can try with add more this code at the end of functions.php file to defer JS from Penci Facebook Widget:

    function penci_mind_defer_scripts( $tag, $handle, $src ) {
      $defer = array( 
        'penci-facebook-js'
      );
      if ( in_array( $handle, $defer ) ) {
         return '<script src="' . $src . '" defer="defer" type="text/javascript"></script>' . "\n";
      }
        
        return $tag;
    } 
    add_filter( 'script_loader_tag', 'penci_mind_defer_scripts', 10, 3 );
    

    For youtube - the script come from youtube embed code itself, so you can't do that..


    Best Regards,

    PenciDesign

  • upsangel replied

    Thank you the defer js for penci facebook works. 

    The youtube is called by the Penci Video Playlist element where a youtube link is put in. Can I defer the JS of  Penci Video Playlist? Seems that the js for Penci FB is penci-facebook-js, do you think it's good to try penci video? If so what is its JS's name please? thank you!

  •  2,699
    PenciDesign replied

    Hi,

    With Penci Video Playlist - we don't enqueue any javascript. We're using youtube API to get video data and use iframesmile.png That's why no any javascript enqueue here.


    Best Regards,

    PenciDesign