YUI Compressor: Keep Some Comments
Info by Progger99 | 2012-02-19 at 23:41
By using the YUI Compressor from Yahoo, JavaScript and CSS files can be compressed so that they use less space - unnecessary comments, blanks and white space are removed, so that the file becomes smaller and can be delivered faster when loading a website.
Reserve Important Comments
However, it is not always desired to actually delete all of the comments in the file. What is with important comments such as a copyright notice at the beginning of the file? This should finally actually remain in the file and should not be deleted.
Exclamation Mark to Keep
Luckily, there is a solution for this problem in the YUI Compressor. We simply write this in our original file:
/*! this comment is kept */ function(a, b, c) { /* this comment will be deleted */ return a + b + c; }
All comments, beginning with */! will be kept, while all other comments will be deleted. After minimizing, our file will look like this:
/* this comment is kept */ function(a,b,c){return a+b+c;}
About the Author
The author has not added a profile short description yet.
Show Profile
Related Topics
Website Performance: Deliver JavaScript and CSS files compressed to reduce loading times
Tutorial | 0 Comments
CSS: Include CSS Stylesheets in HTML
Tutorial | 0 Comments
Reload Images, CSS, JS and Web Pages despite Browser Cache
Tip | 2 Comments
PHP: GZip compress files with PHP
Tip | 1 Comment
jQuery: CSS Stylesheet Switcher
Tutorial | 1 Comment
Rename File to its Folder Name
Tutorial | 0 Comments
How to resize Image before Upload in Browser
Tutorial | 13 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.