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.






Comments

navya said…
Wow. This really made my day. Thanks a lot!

JavaScript Training in CHennai HTML5 Training in Chennai HTML5 Training in Chennai JQuery Training in Chennai JQuery Training in Chennai JavaScript Training in Chennai JavaScript Training in Chennai

navya said…
Wow. This really made my day. Thanks a lot!

JavaScript Training in CHennai JavaScript Training in CHennai JQuery Online Training JQuery Online Training
HTML5 CSS3 JavaScript Training in Chennai | HTML5 Online Training

Popular posts from this blog

Proper way to have an anchor tag with onclick event

Some thoughts on MongoDB Nodejs driver

CORS issues with IE9 and workarounds