JSMin with sourcemaps!
Also available as a grunt plugin!
Synopsis
JSMin is a JavaScript minifier that removes whitespace and comments.
Source maps enables developers to view and interact with minified JavaScript as if it were unminified (providing useful line errors and easier debugging).
When you combine both of these, you get a node module that is your new best debugging friend.
Getting Started
Install the module with: npm install jsmin-sourcemap
Demos
The folders in demo
are hosted on Plunker for your testing and enjoyment.
- Basic http://embed.plnkr.co/mGHUpe
- jQuery http://embed.plnkr.co/JyNn5e
- Multi http://embed.plnkr.co/FPkQx6
Documentation
JSMin is a standalone function which takes the following format of paramters
/** * JSMin + source-map * @param * @param * @param * * SINGLE FILE FORMAT * @param * @param * * MULTI FILE FORMAT * @param * @param * @param * * @return * @return * @return */
Examples
Single file
// Load in jsmin and jQueryvar jsmin = jquerySrc = fs; // Process the jquery source via jsminvar jqueryMinObj = ; // Minified code is available at// jqueryMinObj.code; // Sourcemap is available at// jqueryMinObj.sourcemap;
Multiple files
// Load in jsmin, jQuery, and underscorevar jsmin = jquerySrc = fs underscoreSrc = fs; // Process the jquery amd underscore source via jsminvar indexMinObj = ; // Minified code is availabe at// indexMinObj.code; // Sourcemap is availabe at// indexMinObj.sourcemap;
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via grunt and test via npm test
.
Donating
Support this project and others by twolfson via gittip.
Unlicense
As of Dec 04 2013, Todd Wolfson has released this repository and its contents to the public domain.
It has been released under the UNLICENSE.
Previous to this, it was licensed under the MIT license.