What’s the point of wrapping javascript code in <!-- --> ?
What’s the point of wrapping javascript code in <!– –> ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is one of my pet peeves. This is an ancient developer practice to “protect” older browsers that didn’t understand
<script>tags. Without it, they might fail to load the page or display the script content as html content.But we’re talking ancient browsers here. The only browsers that ever failed on parsing javascript were 1995 era browsers. These browsers are simply not in use today. This practice is just a holdover from 90’s era web development.
No one should ever be putting
<!-- -->blocks around their script tag content anymore.If you see developers that are still doing this, please correct them. Not parsing javascript hasn’t been an issue since Netscape 1.0, and this practice is actually considered harmful for modern browsers.