JavaScript comment starting with /*!

前端 未结 3 1747
孤街浪徒
孤街浪徒 2020-12-16 22:55

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

3条回答
  •  情书的邮戳
    2020-12-16 23:49

    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.

提交回复
热议问题