Is it standard not to declare type="text/javascript" within <script>?

Asked 1 years ago, Updated 1 years ago, 114 views

When I ran Validation, I found the above. In <script>, type="text/javascript" is interpreted as unnecessary When I searched the contents in the hash code, it said that the standard is to use type="text/javascript", so I'm confused I wonder if the content mentioned in the validation is correct with what I interpreted.

fast-frontend type javascript standard script

2022-09-22 18:51

2 Answers

Hello, I'm Yamoo.

If you look at the grammar test results, it is not an error, but a Warning. :-D

Since the DTD of the written document is HTML5, the attribute is informed that it is unnecessary.

In other words, it's okay to omit. (Unlike HTML 4.01)

The MIME type standards for invoking JavaScript to documents are as follows:

<script type="application/javascript"></script>
<script type="application/ecmascript"></script>

However, there is also an older IE (<=8) compatibility issue, so if you omit it from HTML5 documents, The browser will process it automatically.

For a more detailed explanation, Is there a language in the html document other than javascript?Please refer to the article and read it. :-)


2022-09-22 18:51

It depends on which standard you use. HTML4 should be included, and 5 is optional.


2022-09-22 18:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.