rgrove / jsmin-php

:skull: PHP port of Douglas Crockford's JSMin JavaScript minifier. No longer maintained.
423 stars 128 forks source link

Preserve important comments e.g. copyright/ license information #8

Closed adamjimenez closed 13 years ago

adamjimenez commented 13 years ago

JSMin should preserve important comments e.g. copyright or license info. Otherwise webmasters could unknowingly be infringing on copyright when including 3rd party code.

YUI compressor gets around this by checking for important comments e.g: /! Somthing very important /

See more about this issue: http://zoompf.com/blog/2009/11/jsmin-important-comments-and-copyright-violations

And a fork of JSmin that has solved this problem: http://fmarcia.info/jsmin/test.html

rgrove commented 13 years ago

Please file an issue against Douglas Crockford's canonical JSMin repository here: https://github.com/douglascrockford/JSMin

jsmin.php is meant to be a faithful port of jsmin.c, not a fork with new functionality.

adamjimenez commented 13 years ago

JSMin gives a command line option to include comments.

e.g. jsmin jslint.js "(c)2002 Douglas Crockford"

Can this be included?

rgrove commented 13 years ago

jsmin.php itself is a library, not a command line tool, but you could certainly write a command line tool that wraps it and does this. It would just need to prepend any desired comments to the output of JSMin::minify.

Alternatively, you can do this in your scripts:

$js = '/* My awesome comment */' . JSMin::minify($js);