[wd_asp elements=’search’ ratio=’100%’ id=1]

Fix Defer Parsing of Javascript – Gtmetrix WordPress

13th April 2019

Wordpress - Miscellaneous

wordpress category

Defer JS in WordPress by adding this to the functions.php file. Beware this may screw up your website, so be careful with it, and make a backup of your functions.php file.


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 );