最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - Strange comment syntax javascript. Forward slash star exclamation mark - Stack Overflow

programmeradmin2浏览0评论

I was trying to do some stuff but came across a strange comment syntax. Forward slash star exclamation mark.

/*!

Dose it have a special meaning, do anything, or what does it represent?

One example is:

/*!
 * jQuery JavaScript Library v1.8.3
 * /
 *
 * Includes Sizzle.js
 * /
 *
 * Copyright 2012 jQuery Foundation and other contributors
 * Released under the MIT license
 * 
 *
 * Date: Tue Nov 13 2012 08:20:33 GMT-0500 (Eastern Standard Time)
 */

I was trying to do some stuff but came across a strange comment syntax. Forward slash star exclamation mark.

/*!

Dose it have a special meaning, do anything, or what does it represent?

One example is:

/*!
 * jQuery JavaScript Library v1.8.3
 * http://jquery.com/
 *
 * Includes Sizzle.js
 * http://sizzlejs.com/
 *
 * Copyright 2012 jQuery Foundation and other contributors
 * Released under the MIT license
 * http://jquery.org/license
 *
 * Date: Tue Nov 13 2012 08:20:33 GMT-0500 (Eastern Standard Time)
 */
Share Improve this question edited May 31, 2016 at 21:41 razzed 2,68325 silver badges27 bronze badges asked Feb 17, 2014 at 15:18 AndersAnders 10.1k7 gold badges31 silver badges36 bronze badges 2
  • It was in regards to a minifier this occurred. Seems relevant to metion ;P – Anders Commented Feb 17, 2014 at 15:36
  • a.k.a. "forward slash star bang" – razzed Commented May 31, 2016 at 21:01
Add a comment  | 

3 Answers 3

Reset to default 19

The /*! tells the JavaScript minifier to not remove the comment. This is important for license information that has to stay in the file. See Skip License/Credit Comments when minifying JavaScript using YUIcompressor

This is used with uglify. If you use /*! uglify won't remove the comment. You can also use @preserve.

Nope, the ! doesn't mean anything in there, as far as the JavaScript standard is concerned.

It's just a basic comment block with some eye candy. Like this, in it's basic form:

/*
*/

However, as erjiang answered, it has meaning for some minifiers.

发布评论

评论列表(0)

  1. 暂无评论