Defer parsing of JavaScript For Wordpress And Blogger

Defer parsing of JavaScript
Defer parsing of JavaScript 

If you want to cut down the loading time of your website, you can try parsing JavaScript.
In this article, we are going to share several ways to postpone JavaScript and fix this warning and finally, without having to throw this error, load the website faster!

How To Defer Parsing of JavaScript In Wordpress

  1. Using WordPress plugins

  1. Download the Async Javascript plugin here. Or Like Speed Booster Plugin

  1. Click on Plugins > Add New > Upload plugin and select the file you have just downloaded.
  2. Click on Activate of the installed plugin.
  3. Go to Plugins and click on Settings for the Async plugin Or Speed Booster you have just installed.
  4. Clicking on Enable Async Javascript, or Apply Async as two of the most common ways to apply the fix.
  5. Test your website, to see that everything is still working well.

How To Defer Parsing of JavaScript In Blogger

Defer Multiple Javascript Files By Many Script

For all, you need to open your website's HTML file and put the following code in the <HEAD> section
code------------

Copy And Paste This Code





<script>
function parseJSAtOnload() {
var element = document.createElement("script");
element.src = "your_script.js";  //<-- Enter the script which you want to defer.
document.body.appendChild(element);
}
if (window.addEventListener)
window.addEventListener("load", parseJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", parseJSAtOnload);
else window.onload = parseJSAtOnload;
</script>

Defer Multiple Javascript Files in One Script

This script is used to defer multiple files of js. Just you have to put this code in your HTML file.
Change your original scripts to your_script1.js, your_script2.js, your_script3.js and so on.

Copy And Paste This Code



<script>
function parseJSAtOnload() {
var links = ["your_script1.js", "your_script2.js", "your_script3.js"],
headElement = document.getElementsByTagName("head")[0],
linkElement, i;
for (i = 0; i < links.length; i++) {
linkElement = document.createElement("script");
linkElement.src = links[i];
headElement.appendChild(linkElement);
}
}
if (window.addEventListener)
window.addEventListener("load", parseJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", parseJSAtOnload);
else window.onload = parseJSAtOnload;
</script>



source Of Code:johnpatel