Skip to content
Public Ticket #32548

Defer Loading the JS of Penci Facebook and Youtube

Conversation thread

PenciDesign replied

Staff Reply

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

upsangel replied

Customer Reply

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!

PenciDesign replied

Staff Reply

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 started the conversation

Conversation Start

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!

Want to join this conversation or access attachments? Sign in first.