tedious / JShrink

Javascript Minifier built in PHP
http://www.tedivm.com
BSD 3-Clause "New" or "Revised" License
749 stars 152 forks source link

Documentation: flaggedComments #127

Open splitbrain opened 1 year ago

splitbrain commented 1 year ago

It seems the API of this library is quite simple right now (I like it). However there's an option array being passed to the minify method. That options array seems to be undocumented currently. From a quick look at the code, the only option available is flaggedComments which can be true or false. But I am not sure what exactly this option does.

Could you describe what the option does?

tedivm commented 1 year ago

Waaaay back in the day the Yahoo UI Compressor added a feature to preserve licenses. Basically if your multiline comment started with /*! instead of just /* then the Yahoo UI Compressor would not strip that comment out. This way libraries that wanted their licenses to be preserved even through minification could do so.

JShrink added that option and made it configurable through the flaggedComments value.

These days javascript compilers will still remove those comments but store them elsewhere. Webpack, for example, rips them out and stores them in a separate "licenses.txt" file. This way they don't violate the whole "attribution" portion of the licenses by stripping them out.