|

How to Defer Parsing JavaScript Files in WordPress

No votes yet.
Please wait...

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..

Similar Posts

7 Comments

  1. If I use the plugin speed buster Pack Do I have to use this code too ??

    No votes yet.
    Please wait...
  2. Hi Muhammed Bhai,

    Thanks for the Awesome tutorials on your blog !

    I have put the same code on my websites function.php file and the end result of the defer parsing of Javascript score in GT Metrix is F 0… Can you please let me know, what is the mistake I am making.. !

    Regards,
    Aashish

    No votes yet.
    Please wait...
    1. Maybe your theme doesn’t support the defer parsing JavaScript coding. Ask your theme developer and I hope you will get the exact answer. Thanks.

      No votes yet.
      Please wait...
  3. That’s really amazing article shared by @Muhammad Haroon brother. I love it and it really helped me to increase the page speed of my site.

    Thanks for sharing.

    No votes yet.
    Please wait...
  4. Works like a charm. Thanks for the hint. My site speed increased

    No votes yet.
    Please wait...
  5. Thanks for the tutorial. I used some of the information from this article to speed up my wordpress blog. Works better than optimization plugins 😛

    No votes yet.
    Please wait...
    1. I know that’s why I shared this defer parsing js piece of code on my blog. thanks for stopping by.

      No votes yet.
      Please wait...

Leave a Reply

Your email address will not be published. Required fields are marked *