Softstribe

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 is a WordPress developer and technical SEO specialist with over 12 years of experience building, optimizing, and maintaining websites. He specializes in WordPress, WooCommerce, server optimization, DNS, Cloudflare, website security, and performance improvements. Through Softstribe, he shares practical guides, tutorials, and industry insights based on real-world experience helping businesses grow their online presence.
More from Muhammad Dilawar