Wordpress

How to Defer Parsing JavaScript Files in WordPress

May 20, 2014

It is a series article about solving problems from WordPress in order to speed up WordPress blogs. In this article, you will learn to solve how to defer parsing JavaScript in WordPress. The other similar WordPress speed up solved issues can be found here. What actually Defer parsing of JavaScript does? It reduces the initial page load of your page.

If you are looking to boost up your blog add the following code snippet in your WordPress theme’s functions.php file before closing PHP tag ?> (if there is one):

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

Once done. Try testing your WordPress blog using online website page speed testing tools. Comment below if you have any question..

Muhammad Dilawar
Muhammad Dilawar
Muhammad Dilawar founded Softstribe and has spent 12+ years building and speeding up WordPress sites, from WooCommerce stores to Cloudflare and server setups. A Top Rated freelancer on Upwork with a 100% recommendation rate, his client work has generated over $500K in revenue.
More from Muhammad Dilawar →