How to Combine External JavaScript files in WordPress


Combine External JavaScript

Many website designers make multiple JavaScript files to work easier with each JS file. But it completely affects your website page speed to load. Each JavaScript file takes time to load, so the browser has to be download files from all JS files.

For better user experience combine external JavaScript files easily by adding the code into your main js file. Copy external JS file content and paste it to your main JS file. That’s it. Here you are saving some bytes and increasing page speed by making one JavaScript file.

How to Combine JavaScript

To increase page speed you need to combine JS files into one. Let’s take an example If you have a JavaScript file called “main.js” and another called “widgets.js” being called by your HTML. In this situation, you could open your “widgets.js”, copy and paste the contents of the file into “main.js”.After adding this code into main.js, you would remove the call for “widgets.js” from your HTML. Now, all your external JavaScript file calls removed. Now main.js will handle all JavaScript’s for an entire website, which is a great technique to speed up your website.

In WordPress themes, designers make many JS files, it’s better to avoid multiple JS files. Simply Combine all JS in one JavaScript file. Minify and inline small Javascript for even more page speed score and rank.

Leave A Reply

Your email address will not be published.