telling uglify to keep certain comments (using CodeKit)

rgb_life picture rgb_life · Apr 28, 2012 · Viewed 7.9k times · Source

I'm using CodeKit to develop a WordPress theme. Of course I'd like to compress the LESS when it's compiled into CSS, but uglify.js removes all comments.

Does anyone know how to mark specific comments for preservation?

Edit: just wanted to add that after trying this in 2019 with CodeKit 3, the exclamation point trick works perfectly! (Allen Bargi's answer)

Answer

Allen Bargi picture Allen Bargi · Apr 28, 2012

There's convention to put an exclamation mark right after the comment, to preserve it after minifying. you should use something like this:

/*!
  this comment will not be removed by minifiers
 */

The above answer is not valid anymore! things evolve!

Now you should add either @preserve or @license to the comment as mentioned by @texelate below.