![]() into one letter and remove the unused functions and variables. This will change the name of a variable, property, etc. Things like dead_code to remove unreachable code, sequences to join consecutive simple statements using the comma operator, or join_vars to join consecutive var statements.įurthermore, another useful feature to enable is Mangle. To further minify your JS files, it's recommended to implement at least some of the options mentioned in the links above. Using -compress alone will result in a certain level of size savings, however, using only this option will not the provide the savings you could be achieving. If you'll be using the API and need a quick reference to each features list of options, check the following links: The API reference on GitHub outlines a list of options available and also include structure examples. There are myriad of usage options available in UglifyJS. To use UglifyJS for programmatic use: npm install uglify-js To use UglifyJS as a command line app: npm install uglify-js -g There are two slightly different commands which can be used to install UglifyJS depending on your use case. Therefore, you'll need to make sure you have the latest version of Node.js installed. You'll find two repos for UglifyJS on GitHub however, you should reference the most recent one located here. Installing UglifyJSĪs of writing this article, UglifyJS is now in its third version. There are a few different aspects of a website which can be minified including HTML, CSS, and JS, although UglifyJS focusses solely on minifying JavaScript.Īpart from minification, UglifyJS also contains a few other tools that help automate working with JS including:įor the scope of this article, we'll cover how UglifyJS's minification/compression features works and what options available to users. Minification is a valuable performance enhancing technique as it removes whitespace and unnecessary characters within a file to make it smaller and thus, load faster. UglifyJS is best known as a JavaScript minifier.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |