Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why /*@ isn't a comment in JavaScript?

This script http://html5shiv.googlecode.com/svn/trunk/html5.js looks like a big comment, but it works. Why /*@ doesn't behave like a comment?

like image 847
Larry Cinnabar Avatar asked Apr 08 '11 13:04

Larry Cinnabar


2 Answers

This uses a proprietry Microsoft feature called conditional compilation. As far as non-Microsoft browsers are concerned, it is a comment (but they don't need the shiv).

like image 183
Quentin Avatar answered Sep 20 '22 12:09

Quentin


Here some more info and the source.

It is a comment - multiline comment. All browsers suports comments ( // or /* ... */ ) in JavaScript. But only IE checks for the @ in the comment and recognize the part of the script for the conditional compilation. This is for usage of the non-standart Microsoft features.

There is also conditional commentsMSDN in HTML, which will be removed in IE10.

like image 29
Bakudan Avatar answered Sep 18 '22 12:09

Bakudan