Javascript minification will generally remove all comments from source. This means that license information is also removed.
If I run a big site, and I want to abide by licenses, does that mean that I cannot use automatic minification? There is no option to "preserve the first comment, but not the others " right?
I ask because a rather big company has used some code I wrote and not included my (MIT) license, but before I get all peeved, I want to put myself in their shoes.
edit:
It seems that as the author the burden is on me to comment the license in such a way (see answers) that it does not get removed during the minification. I am OK with doing that first, and then raising a stink if my license is still removed
It is important to minify your CSS and minimise JavaScript files so they can load faster on your web pages. There are many reasons why you should minify your CSS and JavaScript: Reduce file size: The more code there is in a file, the larger it will be. Minified code is usually much smaller than the original version.
Minifying, or minification, is where you remove unnecessary characters from your code, whether they might be whitespace (such as indentation), code that isn't ever used, comments in your code or long names for variables that can be replaced with something shorter.
Minification is the process of minimizing code and markup in your web pages and script files. It's one of the main methods used to reduce load times and bandwidth usage on websites. Minification dramatically improves site speed and accessibility, directly translating into a better user experience.
Go to minifycode.com and click the CSS minifier tab. Then paste the CSS code into the input box and click the Minify CSS button. After the new minified code is generated, copy the code. Then go back to the css file of your website and replace the code with the new minified version.
This is a classic case of "it depends".
It depends on the minifier. For example UglifyJS will leave in the initial comment block in a file unless you specifically tell it not to with the -nc
flag. Others (like Google's Closure Compiler) look for a special annotation (e.g., @license
or @preserve
). Some respect "loud" comments (e.g., /*! ... */
) while others don't.
It depends how you minify. Some organization are aggressively minifying and concatenating everything to squeeze out every byte. Others are adding the licenses in source control and "leaving them in" during minifying. Others are applying license files after everything has been concatenated together.
It can be easy for some place to drop a license in their production builds, especially if they're aggressively concatenating every library they use into a single JS file. They may not even know that they're doing it. Your best bet here is probably just to reach out and ask them to make sure that they're respecting the terms of the license and leave the license text on there -- they may not even realize that they're doing it.
No! if you used following comment style with YUIcompressor:
/*!
*
*/
The exclamation tells the compressor to retain the comment.
Here is Documented Notes for these comments
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With