Search code examples
javascriptgeany

JavaScript comment starting with /*!


My editor (Geany) changes the colour of a comment when a comment starts with /*!. What's the difference between /* ... */ and /*! ... */?


Solution

  • The ! prevents YUI compressor from removing the comment when it compresses. (It just removes 1 ! instead. Multiple !'s mean you can compress multiple times without loss of the comment.) It's just an extension, but not part of javascript itself.

    Documentation is here. Search for 'C-style comments'.

    also, I'm not aware of any other compressors that respect the !. Packer, closure compiler, shrinksafe, and jsmin do not respect it at least.