The purpose of starting an initial comment with /*! in javascript and css files

I've noticed that initial comment in javascript or css files is sometimes started with /*! What is the purpose of the explanation mark?

For example, jquery.js:

/*! jQuery v1.7.1 | */


 * Bootstrap v2.0.1
 * Copyright 2012 Twitter, Inc



It tells compression tools such as the YUICompressor and Uglify, which minify the code, to leave the commented section in place as they usually remove all comments from the code.


I believe one purpose of the exclamation point is to tell javascript minifiers to leave these particular comments in, when condensing the files.


Some software like Coda also support the "bookmark syntax" shown below, so that one can navigate to different parts of code through the app's code navigator.

// !bookmark
/* !bookmark */
<!-- !bookmark -->

Note that in the examples above there's a space between the comment syntax the exclamation mark.


It is also important for attribution for the author of external dependencies/API, especially free ones.

When minifying, the least we can do is to offer them some bytes of recognition.

e.g. /*! PhotoSwipe main CSS by Dmitry Semenov | | MIT license */ will not be erased by minifier.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.