In HTML5, you can embed JavaScript code directly in the page and include external JavaScript files. The syntax for embedded scripts is "3f1c4e4b6b16bbbd69b2ee476dc4f83a2cacc6d41bbb37262a98f745aa00fbf0", and the syntax for external scripts It is "1d6bc41909296d18fd295bdfb5aeab612cacc6d41bbb37262a98f745aa00fbf0".
In HTML5, js code can be used in two ways (embedded script and external script) through the 3f1c4e4b6b16bbbd69b2ee476dc4f83a tag. The following article will introduce it to you, I hope it will be helpful to you.
Two ways to use js in html5:
Embedded script:
<script> //js代码 </script>
External script:
<script src="外部js脚本文件"></script>
Advantages of external script:
● Maintainability● Cacheable: The browser can cache all external JavaScript files linked to based on specific settings● Adaptable to the future3f1c4e4b6b16bbbd69b2ee476dc4f83a tag
3f1c4e4b6b16bbbd69b2ee476dc4f83a element has two commonly used attributes:
Note: The 3f1c4e4b6b16bbbd69b2ee476dc4f83a element with the src attribute should not contain additional JavaScript code between its 3f1c4e4b6b16bbbd69b2ee476dc4f83a and 3f1c4e4b6b16bbbd69b2ee476dc4f83a tags. If embedded code is included, only the external script file will be downloaded and executed, and the embedded code will be ignored. JavaScript files from external domains can also be included via the src attribute of the 3f1c4e4b6b16bbbd69b2ee476dc4f83a element.
Example:<script src="example.js"></script> <script src="//m.sbmmt.com/js/example.js"></script>● Type: Specifies the MIME type of the script. The type attribute indicates the content between the 3f1c4e4b6b16bbbd69b2ee476dc4f83a and 2cacc6d41bbb37262a98f745aa00fbf0 tags.
Description: MIME type includes two parts: media type and subtype. For JavaScript, the MIME type is "text/javascript".
Note: In HTML5, the type attribute is no longer required. The default value is "text/javascript". JavaScript is the default scripting language in HTML5 and all modern browsers.
Recommended video tutorials: "