HTML comment within <script> tags | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

HTML comment within <script> tags

Are HTML comments within script tags ignored? Or does commented out code not run? For example: <script> <!-- window.onload = alert('test'); --> </script>

12th Nov 2018, 1:46 PM
Brendon Bosman
Brendon Bosman - avatar
2 Answers
12th Nov 2018, 2:00 PM
Arushi Singhania
Arushi Singhania - avatar
+ 1
Thanks. I've seen it being used on a website but it seemed to be done as a form of code obfuscation. It used unescape('long string of characters'); I assume it's to prevent web scraping maybe.
12th Nov 2018, 2:04 PM
Brendon Bosman
Brendon Bosman - avatar