Load last / defer Javascripts

COntent

Add to functions.php of your theme / child theme

/**
 * Deferring parsing of JavaScript
 */
function defer_parsing_of_js ( $url ) {
    if ( FALSE === strpos( $url, '.js' ) ) return $url;
    if ( strpos( $url, 'jquery.js' ) ) return $url;
return "$url' defer ";
}
add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
ABOUT

Wordpress Code Tricks

Your WP Code Snippets Central

Sign up now to get access to the library of members-only issues.

TAG FILTER