How to determine the procedure of the search engine optimization of a website
How to optimize the JavaScript code to speed up website loading
Why is it important to optimize the JavaScript code?

How to truncate the JavaScript code?

Before compressing the code, create a backup copy of it on your computer to avoid website crashes in case of errors.
Another popular tool for script code reduction is Google's Closure Compiler. The service interface consists of two vertical fields. Paste the JS code in the field on the left:

Before: i=i+1;
j=j-1;
After: i++;
j--;
if( age >= 21) {
var message = "Allowed";
} else {
var message = "Prohibited";
}
var message = age >= 21 ? "Allowed" : "Prohibited";
constant welcome = 'Hello' + Name + ' ' + Surname + '!';
constant welcome = `Hello ${Name} ${Surname} !`;
Previously, SEOs could not check pages with JS scripts for technical issues with our Audit, because it did not see the content there. Now the tool can render JS pages and check them for technical issues! Read more about the update and why you need it below.
Leave a request, and our experts will advise you on the development of your project, share training materials, and offer test access to Serpstat!
Conclusion
Replace ordinary variables with their reduced versions after removing spaces, comments, and extra lines. Optimization of the JS code for websites on WordРress and other CMS can be carried out using built-in plugins. The manual optimization of JavaScript does not have as much effect as connecting additional plugins.
For more efficient compression, it is better to use such libraries as Gulp, Webpack, and others.

Run Site Audit |
Learn how to get the most out of Serpstat
Want to get a personal demo, trial period or bunch of successful use cases?
Send a request and our expert will contact you ;)
Recommended posts
Cases, lifehacks, researches and useful articles
Don’t you have time to follow the news? No worries!
Our editor Stacy will choose articles that will definitely help you with your work. Join our cozy community :)
By clicking the button, you agree to our privacy policy.
Comments