HomeSEOHow to defer parsing...

How to defer parsing of JavaScript in WordPress – Guide

Why we should work on “defer parsing of JavaScript.”

Performance and speed are most important to run a website. There are many techniques to speed up your website with “Defer Parsing of JavaScript.”

But before continue, you need to understand the reason why we should work on “defer parsing of JavaScript.”

The JavaScript mostly placed between <head></head> tags. When opening a website, it always loads the code from top to bottom. If lots of JavaScript are placed in the head section, the website will take more time to load.

After “defer parsing of JavaScript,” the website will not wait for JavaScript codes to load. That means the website will load quickly.

After implementing the steps below, you will find the results like this or Maybe much improved.

There are too many Plugins that can do the same job. But I will recommend Deferring parsing JavaScript by placing a code in the function.php file.

You can do this by accessing the function.php file using FTP or installing a small plugin “Theme editor” quickly.

Check out: How to speed up your WordPress Website using .htaccess

Don’t ever forget to keep a backup of your original file so you can back up if you found any problem on your website.

  1. The file “Function.php” is located in your WordPress theme directory. Go to /public_html/yourwebsite.com/wp-content/themes/active theme/function.php. Open the file, paste the code at the bottom of the “file,” and feel the magic.

Or

  1. Install “Theme Editor

Go to settings>>Theme Editor>>Your active theme>>function.php

Add the code at the bottom of the file. Save and enjoy

The Code (Defer Parsing of JavaScript)

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

Test your website again, and feel the difference. You can uninstall the “Theme Editor” Plugin after completing this job.

There are some plugins that you can also try for the same job. But as I am not recommending any plugin to Defer Parsing of JavaScript, I will not discuss these Plugins in detail.

  1. WP Deferred JavaScript
  2. Speed Booster Pack
  3. Async JavaScript

 

Most Popular

More Articles

Choosing The Right Images For Your Website Design

When you plan to create your own website, one of the...

Books Begone! How do People Read in 2022

It goes without saying that people consume literature in a completely...

How to Check if a Website is Legit or Trying to Scam You

Banking, shopping, and interacting with businesses have all become a lot...

5 Tips To Improve E-commerce SEO

One of the most critical aspects of an e-commerce site is...

Read Now

Top 6 Digital Marketing Strategies You Must Follow

One of the best digital marketing techniques is word of mouth. Every person has the same intention that if they get positive reviews about a particular service, then they tend to utilize it.In this case, as a digital marketer, you have to take care of your services...

How SEO Services Can Benefit Your Brand In 2023    

Do you want to gain the maximum benefit from SEO services? If yes, you have to follow certain tricks to help you meet your goals within a specific time. Proper schemes can make things work for you in the correct direction.Without appropriate SEO services, your company cannot...

How to calculate Ad Revenue & 7 ways to increase it

Estimating how much revenue a business makes can be tough but leveraging the right tools that accurately estimate publishers' ad earnings makes it a bit easier.Many variables influence your ad revenue, such as the layout of the site, the number of ads, visitor demographics, ad viewability, etc....