Is <script> <! - // -> </script> useful more

I am looking at some html released abroad for developers. They use comments inside their external script loading tags - as far as I know, this was only useful for very old javascript non-obvious browsers that used to render scripts as text - is there any modern purpose for this or is it now completely redundant?

<script type="text/javascript" src="path/to/file.js"><!--//--></script> 

Thank you in advance

// Update after comments below: It turns out that comments cracked the problem in the content management system, where it would display the tag as

 <script type="text/javascript" src="path/to/" /> 

without any comments present - so the answer is that they can use any use in general web development, but there are some specific circumstances in which they can be useful. Kudos to Caspar Kleine for this.

+4
source share
4 answers

No, this is no longer useful.

This was used back when there were still browsers that were submitted before Javascript existed. Currently, every browser is aware of the existence of Javascript, even if it does not support it.

If someone else has such an ancient browser, it won’t, your page will look so terribly crappy that it doesn’t matter.

+5
source

Since you include it from an external file, there should be no use for it.

+4
source

It always depends on your target group. You can check your site’s statistics to see if there are a significant number of people using old old browsers, and then decide. This is unbelievable, you will find a lot, if any.

Personally, I don't comment on JavaScript code.

But in sidenote - using <noscript> is still important, perhaps more than ever now during ajax-driven sites.

0
source

It does not have to go forward and often stops, although it may be an attempt to standardize XHTML, where CDATA is commonly used. This question contains a lot of information: When is a CDATA section needed in a script tag?

Being intended for XHTML or to support an old browser, it doesn’t hurt anything, although it almost certainly doesn’t help. This may help support some archaic browsers, but if you do not test them specifically, your site will not work properly. Leave this if you are not using XHTML.

0
source

Source: https://habr.com/ru/post/1344911/


All Articles