

Then, you can change the main-built.js file name to just main.js so the HTML page will load the optimized version of the file. Change the out= option to any directory you like, that has a copy of your source. Normally you would save them to a copy of your project, but to make this example easier it is saved with the source. Normally you should not save optimized files with your pristine project source. This will create a file called appdirectory/scripts/main-built.js that will include the contents of main.js, one.js, two.js and three.js. /r.js -o name=main out=main-built.js baseUrl=. Use the above example setup, if you just wanted to optimize main.js, you could use this command, from inside the appdirectory/scripts directory: node. In other words, the mainConfigFile configuration has the lowest priority. The precedence for config: command line, build profile, mainConfigFile. Or: define(, function (a, b) ) found in that file will be parsed out and used as part of the configuration options passed to the optimizer: mainConfigFile: 'path/to/main.js'
#HTML OPTIMIZER DOWNLOAD MODS#
So, it will not find modules that are loaded via a variable name: var mods = someCondition ? : īut 'a' and 'b' will be included if specified like so: require()

The optimizer will only combine modules that are specified in arrays of string literals that are passed to top-level require and define calls, or the require('name') string literal calls in a simplified CommonJS wrapping.
#HTML OPTIMIZER DOWNLOAD CODE#
The optimizer is part of the r.js adapter for Node and Nashorn, and it is designed to be run as part of a build or packaging step after you are done with development and are ready to deploy the code for your users. Optimizes CSS by inlining CSS files referenced by and removing comments.Combines related scripts together into build layers and minifies them via UglifyJS (the default) or Closure Compiler (an option when using Java).RequireJS has an optimization tool that does the following empty: paths for network/CDN resources § 7.Shallow exclusions for fast development § 6.

As a result, it can't create a partial/malformed tree at the time of the output.
#HTML OPTIMIZER DOWNLOAD FULL#
HTMLMinifier can't know that original markup was only half of the tree it does its best to try to parse it as a full tree and it loses information about tree being malformed or partial in the beginning. Transformation of internal representation (e.g. Parse input according to HTML5 specificationsĪrray of regex'es that allow to ignore certain comments, when matchedĪrray of regex'es that allow to ignore certain fragments, when matched (e.g. Use direct Unicode characters whenever possible )Īrrays of regex'es that allow to support custom event attributes for minifyJS (e.g. ng-class/)Īrrays of regex'es that allow to support custom attribute surround expressions (e.g. Regex that specifies custom attribute to strip newlines from (e.g. Must be used in conjunction with collapseWhitespace=trueĪrrays of regex'es that allow to support custom attribute assign expressions (e.g. Must be used in conjunction with collapseWhitespace=trueĬollapse white space that contributes to text nodes in a document treeĪlways collapse to 1 space (never remove it entirely). Omit attribute values from boolean attributesĭon't leave any spaces between display:inline elements when collapsing. Treat attributes in case sensitive manner (useful for custom HTML tags) Most of the options are disabled by default. How does HTMLMinifier compare to other solutions - HTML Minifier from Will Peavy (1st result in Google search for "html minifier") as well as and minimize? Site See corresponding blog post for all the gory details of how it works, description of each option, testing results and conclusions.Īlso see corresponding Ruby wrapper, and for Node.js, Grunt plugin, Gulp module, Koa middleware wrapper and Express middleware wrapper.įor lint-like capabilities take a look at HTMLLint. HTMLMinifier is a highly configurable, well-tested, JavaScript-based HTML minifier.
