I just like to ask what the title says. The following string required into HTML script tags?
<!-- //-->
If I don't use them what would happen?
JavaScript has become integral to the Internet experience as developers build increased interaction and complexity into their applications. Search engines, ecommerce, content management systems, responsive design, social media and phone apps would not be possible without it.
JavaScript is Must For Web Development. JavaScript is the most popular and most widely developed programming language ever existed. JavaScript is a must-have for Web developers, Front-end/ Back-end developers, Mobile / Desktop developers, Graphics / Game developers and even for Full Stack developers as well.
Can I learn JavaScript without knowing HTML and CSS? Yes, by learning Node JS which doesn't require HTML and CSS, unlike traditional web applications. Additionally, you can also learn JavaScript topics that can be executed independently in the JS compiler such as declarations, scopes, closures, ES6 classes, etc.
The worse thing that can happen is that your page is retrieved by a user agent that's not aware of the <script>
tag and tries to parse your script block as regular HTML. JavaScript code will be handled as regular text and <
symbols might interfere with the page markup. A forced example:
<script type="text/javascript"> if(a<del || a>b){ foo(); } </script> Lorem ipsum dolor sit amet.
... could render as ugly deleted text:
if(ab){ foo(); } Lorem ipsum dolor sit amet.
Do these obsolete user agents exists? Oh, sure they do. Please note I've carefully avoided the word "browser". The question is not who's using Mosaic nowadays. It's that a your site can be read by a poorly-written PHP-powered regexp based parser.
Should you care? Well, probably not :)
Not unless you are targeting browsers that predate the <script>
element (i.e. Netscape 1 and friends). (Hint: You aren't).
If you don't use them, and a browser that old (so old it can't even cope with the HTTP Host header which is needed for sites that use virtual hosts) tries to access the site, then the content of the <script>
element will be treated as text to be displayed.
Further reading: Comments and CDATA: The mysterious history of script and style in HTML
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With