0

I have a couple scripts I've inherited to say the least. These scripts work flawlessly in Chrome and FireFox but IE not so much

Today I noticed something while trying to figure it out. I noticed that at the top of the scripts are some comments but they look like

<!-- 
/*
*
* The comment
*
*/
-->

Is the HTML style comments potentially breaking the scripts in IE? the <!-- --> part

mador
  • 1,203
  • 9
  • 13
chris
  • 36,115
  • 52
  • 143
  • 252
  • If that's in a ` – Brad Christie Feb 26 '15 at 20:19
  • Suggest reading this thread... http://stackoverflow.com/questions/808816/are-html-comments-inside-script-tags-a-best-practice – Daniel Williams Feb 26 '15 at 20:20
  • Its within a JS file specifically well a few of them rather. Who ever designed our Grunt flow, has these injected in like this. Which didn't seem right to me.. but it caught my eye since I know IE can be real particular about things, where as FF and Chrome sometimes look past it so to speak – chris Feb 26 '15 at 20:25
  • I just couldn't find reference saying that the combination in the way presented was in so many words, legal.. – chris Feb 26 '15 at 20:25
  • it's not valid to use xml comments in js files, but some vendors might try to fix it for you automatically. – dandavis Feb 26 '15 at 20:45
  • Just how old are these scripts? Are they etched in stone perhaps? – mu is too short Feb 26 '15 at 21:13
  • You would think they should be haha.. but no.. well, no actually maybe some of them are.. – chris Feb 27 '15 at 03:32

2 Answers2

0

The syntax would need to change to

<!-- 
/*
*
* The comment
*
*/ 

//-->

< !-- is a valid js comment, but --> is not

Kevin Seifert
  • 3,494
  • 1
  • 18
  • 14
  • Thats pretty much what I thought, but I couldn't find anything saying yes/no to 100% either way if it was allowable. `//-->` I knew about but yea, overall I believe this solidifies my concern about it. Thanks. – chris Feb 26 '15 at 20:27
0

Get rid of <!-- --> comments inside javascript and stick with /* */.

Daniel Williams
  • 2,195
  • 7
  • 32
  • 53