Retaining license details in javascript files while minifying using YUICompressor

Minification is one of the methods suggested by yahoo's yslow plugin.

During minification process all comments in a javascript file are removed, long variables names are replaced with shorter ones, removing unwanted spaces, removing empty lines, making the minified file size as minimum as possible.

If we are using a third party javascript file whose license should be intact while sending to the outside world. Using YUICompressor 's default setting it removes all the comments while include license info as well.

If you want a comment block not to be removed by compressor while minifying, then that comment block should start with !

For example if the input is

/*! this is my js should include license */
var myFunc = function() {
/* this comment i dont want in minified version*/

Then the output of compression will be like

/*this is my js should include license */
var myFunc= function() {...}

thus retaining the comment after minification as well.


Popular posts from this blog

Proper way to have an anchor tag with onclick event

My FIRE Journey

CORS issues with IE9 and workarounds