Updated on Mar 13, 2019
Method Type: User (.JS)
(this means that the method is handled by the user with the help of a minifying tool or by enabling Mod pagespeed in the .htaccess file)
Mod PageSpeed Support
PageSpeed has been deprecated from our Shared Environment but is still supported on all VPS and Dedicated Server hosting plans.
Status: Must be applied/enabled by the user.
Introduction:
JavaScript is a dynamic, high level programming language. It is one of the three essential technologies used for producing content for the World Wide Web. A JavaScript file (.js) is used mainly for running JavaScript code to execute instructions.
How Minifying JavaScript works:
The minification of a script is the removing of all unnecessary characters from the code to reduce the size thus significantly improving the loading times of the elements on the page. The minification removes all spacing, new lines and developer comments to reduce the size as much as possible.
Minifying JavaScript provides the following Advantages:
Note that you won't be able to minify external JavaScript elements as you can see from the example below.
These elements will lower your score but are beyond your control.
One of the most useful PageSpeed filters is the rewrite_javascript
one, which minifies JavaScript without any additional input from the user.
You can enable the Mod pagespeed by accessing the .htaccess file and adding the following line to it:
ModPagespeed On
You can also minify JavaScript for your website with this tool. Here you can paste you JavaScript and minify it.
You can also upload multiple JavaScript files and compress them into one minified file.
You can check the results in the output tab of the tool.
Congratulations, you have minified your JavaScript scripts.