Add this to your functions.php file and it will speed the loading of the page up. It does this by putting .js files to the back of the queue. It helped me by running YouTube plugins last as they were taking ages to load stopping the user viewing the page.
As soon as I added this it was fixed. the page loaded fast and only inserted the last bits after the page was displayed.
1 2 3 4 5 6 7 8 9 |
function defer_parsing_of_js( $url ) { if ( is_user_logged_in() ) return $url; //don't break WP Admin if ( FALSE === strpos( $url, '.js' ) ) return $url; if ( strpos( $url, 'jquery.js' ) ) return $url; return str_replace( ' src', ' defer src', $url ); } add_filter( 'script_loader_tag', 'defer_parsing_of_js', 10 ); |