How to Defer Parsing of JavaScript WordPress : Optimizing Site Speed

While undertaking site speed test by use of tools like GTmetrix or Google Page Speed Insight, you may be shown with issues such as ‘Defer Parsing of JavaScript’. The question is How to Defer Parsing of JavaScript WordPress?


A detailed analysis of the issue will reveal you a set of JavaScript URLs which may be responsible for the problems.


How to resolve such problems. In WordPress, the question of How to Defer Parsing of JavaScript in WordPress can be answered by following deliberated points.

(i) Use of Plugins to Defer Parsing of Javascript WordPress

There are Plugins like WP Deferred JavaScripts  to sort out such problems. Just install these plugins and activate them. you may get rid of the problems. But the question is how long and how many plugins you are going to use for each and every issue on your WordPress site. After all use of increasing number of plugins have their reverse effect and they are known to cause slower speeds for your site. So use your prudent mind and use plugins only if your configuration permits it.

How to resolve Serve Scaled Images issue from your site
Self Hosted Wordpres Org Site

(ii) Configure W3 Total Cache Plugin

For faster loading of sites, most of us use some sort of CAche plugins. W3 Total Cache Plugin is quite a popular plugin in this series and If you are using this plugin you can configure answer the question of How to Defer Parsing of JavaScript in WordPress. You can go to ‘minify’ option and go to ‘JS’ section. There while keeping the JS minify settings enabled, you can choose the ‘Non-blocking using “defer” option under Before </head> as per the following picture.


Also ensure that in General Settings and Minify subheading, the Minify option is enabled and the Minify mode is checked for the Manual option.

(iii) Use of PHP Codes

You can insert the following PHP code in ‘Funtion.php’ the file just before the closing of PHP tag (?>) to Defer Parsing of JavaScript WordPress.

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

Hope one of the three methods as deliberated above will resolve the problem of how to Defer Parsing of JavaScript WordPress You can even use all the methods to solve the issue.

All the Best.

Comments are closed.