Hello everyone,  Now in this post we are going to add a small code to your functions.php file of your WordPress theme to Defer Parsing of JavaScript in WordPress and hence to speed up your WordPress blog.

Also Read : Leverage Browser Caching in WordPress

Warning :- Before you start editing functions.php file of your theme, make sure to back it up, In case something goes wrong you can restore it back to make your blog working. 

Steps to Defer Parsing of JavaScript in WordPress

  1. Open up the functions.php file in your theme folder either via hosting panel or WordPress editor.
  2. Add up the following code in functions.php file.
  3. function defer_parsing_of_js ( $url ) {
    if ( FALSE === strpos( $url, '.js' ) ) return $url;
    if ( strpos( $url, 'jquery.js' ) ) return $url;
    return "$url' async onload='myinit()";
    add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );
  4. Save your files and check your blog performance.
  5. In most of the cases this work great but if this is breaking your theme you should remove the added code to revert back.

Thank you for reading this post and keep connected to Tech Arrival to continue enjoying wonderful posts. Share your views about this post in comment section below. If you are still having any query throw it in comment section.

If you find this post helpful, don’t hesitate to share this post on your social network. It will only take a moment and also it is quite easy and helpful for others.


CommentLuv badge