Defer or Load Javascript Asynchronously

To load javascript asychronously with the JCH Optimize Pro plugin, simply use the Optimum setting. The plugin will then combine all the javascript files and scripts into one file, places it at the bottom of the document just before the </body> tag and adds the async attribute to the <script/> tag.

Excluded files will not be deferred.  If you're excluding files however while maintaining the original execution order of files on the page, then this behaves differently. The plugin will split the combined file around the excluded files or scripts and place the defer attribute to the <script/> at the bottom of the page. Read the section above called, Excluding files and declaration blocks, to better understand this behaviour. Please note, the excluded files and the combined files above the excluded files will not be deferred.

[Tip]Tip

Please note that the plugin also will exclude some javascript files or script by default that are known to cause issues when combined with JCH Optimize Pro. Check the HTML source of the page to see what was excluded. You can force the plugin to ignore the original execution order of the files on the page by using the second section on the Excludes Option tab called Exclude files without maintaining the original execution order of files on the page if you are sure the excluded files do not have any dependency relationship on any other files. The plugin will then combine all the included files in one and place it at the bottom of the page with the asnyc attribute.

[Important]Important

Please note that if you exclude files without maintaining the original execution order of the files on the page and the excluded files have dependency relationships on other files that are combined you will most likely break your page. If you're not sure then do not exclude files in this manner!

Dynamically loaded files cannot be deferred.  If you're not excluding files and using the Optimum setting but you're still seeing this issue being triggered on GTmetrix or on PageSpeed Insights then most likely this is caused by files that are being loaded dynamically using javascript. This means the links to these files are not embedded in the HTML so the plugin cannot access these files to optimize and combine them. Most times, ironically, these files tend to be Google Analytics, Google Maps, Google Ad files, or social media files. Check the HTML source for the links of the files that are triggering this error. If they are not in the source then it means they were loaded dynamically. In this case there's nothing the plugin can do to address this. The only remedy unfortunately is to avoid using the applications that load these files on your site or on your landing pages to the best extent possible.