[Lectures 1-23] Is there a language that can be used in html documents other than javascript?

Asked 2 years ago, Updated 2 years ago, 118 views

I heard that <script type="> can specify the type and javascript is specified as the default value in lecture 1-23. As far as I know, I heard that HTML css javascript can handle only three things, but does it mean that I can use another script language or programming language if there is a type designation?

fast-frontend html script javascript

2022-09-22 19:34

1 Answers

Hello, I'm Yamoo. -^

-^

In conclusion, ECMAScript (JavaScript) is the only client-side scripting language that works directly from the browser without a plug-in.

However, you can use the plug-in to use ActionScript, Silverlight, Java, etc., or use the compilation process to change Dart, CoffeeScript, TypeScript, etc. to JavaScript.

ECMAScript is the only client-side scripting language because all browsers must implement a unique version of the specification. Therefore, browser manufacturers should focus on supporting standard languages rather than leading them to their own non-standard languages.

Prior to the establishment of the standard, the client site script language had different implementations from manufacturer to manufacturer, so there was a problem of specifying different MIME types.

<!-- Various MIME settings -->

<script type="text/javascript" src="temp.js"></script>

<script type="text/ecmascript" src="temp.js"></script>

<!-- The meaning of x- is unofficially under experimentation -->
<script type="application/x-javascript" src="temp.js"></script>

<script type="text/javascript1.5" src="temp.js"></script>

<!-- Non-standard -->
<script language=”JavaScript” src="temp.js"></script>

To resolve this confusion, the ECMAScript(JavaScript) MIME standard type has been confirmed . Looking at the content, the Javascript program is not appropriate to designate as a text document due to its nature, and we recommend using application/javascript or application/emascript instead.

So if you look at the full list of MIME types , you can see that the standard MIME type for ECMAScript (JavaScript) files with the extension .js is application/javaScript.

<!-- Standard MIME settings -->
<script type="application/javascript" src="temp.js"></script>

<script type="application/ecmascript" src="temp.js"></script>

Unfortunately, the older IE (<=8) browser does not handle it normally, so if your project needs to consider older IE, you must use the text/javascript type.

<script type="text/javascript" src="temp.js"></script>

In HTML5 documents, you can omit the MIME type of the associated style/script document. If you do not explicitly set the MIME type, the browser recognizes it as JavaScript and processes it.

<script src="temp.js"></script>

HTML5 Standard Document states:

The type property allows the user to set the script type.

If you omit the property or set the JavaScript MIME type, it is treated as classical JavaScript. It is better to omit properties rather than setting various MIME types through one or more properties, such as type, language.

The type attribute allows customization of the type of script represented: Omitting the attribute, or setting it to a JavaScript MIME type, means that the script is a classic script, to be interpreted according to the JavaScript Script top-level production. Classic scripts are affected by the charset, async, and defer attributes. Authors should omit the attribute, instead of redundantly giving a JavaScript MIME type.

When using the <script> element in HTML5 documents, it is recommended that you omit the type attribute.


2022-09-22 19:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.