Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

javascript

css

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 jquery.com | jquery.org/license */ 

bootstrap.css:

/*!  * Bootstrap v2.0.1  *  * Copyright 2012 Twitter, Inc 
like image 316
Jan Wrobel Avatar asked Jun 28 '12 15:06

Jan Wrobel


People also ask

What is the purpose of comments in CSS?

A CSS comment is used to add explanatory notes to the code or to prevent the browser from interpreting specific parts of the style sheet. By design, comments have no effect on the layout of a document.

How do you comment a CSS file?

How to Comment in CSS. To comment in CSS, simply place your plain text inside /* */ marks. This tells the browser that they are notes and should not be rendered on the front end.

How do you add notes in CSS?

Like most languages, CSS allows the users to add comments in the stylesheet. Comments in CSS can be added by using the /* tag, which is then closed off by using */ . Note: Code that is commented out is not used to style the page. This technique can be used to add both single and multi-line comments.

How do you comment in style tag?

In CSS, a comment always starts with /* and ends with */ . The reason for the special rules for <! -- and --> is that very long ago (and we are talking about the time when Netscape 1 was still in use), some browsers did not recognize the style element at all.


1 Answers

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.

like image 143
Phil Parsons Avatar answered Sep 22 '22 09:09

Phil Parsons