Minification in Javascript:
Minification means removing/clearing. In javacript, Minification is the process of removing all characters(i.e extra whitespace, comments, new line characters, etc.) from the javascript source code that are not necessary. This process does not change the functionality of the code. Code that has gone through the minification process is also known as minified code and hence javascript is minimized.
How to minifest javascript:
To minifest javascript,
- Try the Closure Compiler, JSMin or the YUI Compressor.
- Create a build process that uses these tools to minify and rename the development files and save them to a production directory.
Installing and Configuring the Closure Compiler Minification Tool:
- Firstly, Download and install the Node.js runtime environment.
- Allow Node.js plugin enabled. The plugin is activated by default. If the plugin is not activated, enable it on the Plugins page of the Settings / Preferences Dialog .
- Allow file Watchers plugin enabled. The plugin is activated by default. If it is not, enable the plugin. .
- Download the compiled tool at https://closure-compiler.googlecode.com/files/compiler-latest.zip, or at http://dl.google.com/closure-compiler/compiler-latest.zip.
- Extract the archive to the folder under the Node.js.
Installing and Configuring the YUI Compressor JS or UglifyJS Minification Tool:
- Download and install Node.js.
- Allow Node.js plugin enabled. The plugin activated by default. If the plugin is not activated, enable it on the Plugins page of the Settings / Preferences Dialog.
- Allow file Watchers plugin enabled. The plugin is activated by default. If it is not, enable the plugin.
Download and install the JavaScript minification tool. Switch to the directory where the Node Package Manager (npm) is stored or define a path variable for it so it is available from any folder.
Depending on the tool you want to use, type one of the following commands at the command line prompt:
To have the YUI Compressor JS installed, type: npm install yuicompressor
To have the UglifyJS installed, type: npm install uglify-js
0 Comment(s)