Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Java by (9.5k points)

I want to know how I can resolve the below output which is reported on GTmetric. I want to  defer the parsing of Javascript in order to decrease the page loading time.


1 Answer

0 votes
by (19.7k points)

You can add the below code to /wp-includes/functions.php:

/* Function for defer parsing of javascripts, for loading the website 

faster */

function defer_parsing_of_js ( $url ) 


   if ( FALSE === strpos( $url, '.js' ) ) 

   return $url;

   if ( strpos( $url, 'jquery.js' ) ) 

   return $url;

   if ( strpos( $url, 'wp-custom-countdown' ) )

   return $url;

   return "$url' defer ";


add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );

Interested in Java? Check out this Java tutorial by Intellipaat.  


Browse Categories