HTML <script> (Scripting) Tag
The <script> element contains statements in a scripting language for client-side processing.
Scripting statements can either be included inline or loaded from an external file.
- If the src attribute is specified, the <script> element should not have a script embedded within its tags.
- The order of the script objects in a document can also be important, especially if scripting event handlers are assigned to one or more elements in the document.
- Using async="async" didn’t work in some older browser, instead async="true" was used.
- Use <noscript> element for users that have disabled scripts in their browser, or have a browser that doesn't support client-side scripting.
Version: HTML 4, 4.01, 5
|Specifies that the script should be executed asynchronously, as soon as it becomes available.
|Whether or not script error information will be revealed from the script(This is used only when scripts are being loaded from different origins).
|Specifies that script should be executed after the document has been parsed.
|Allows a browser to check the fetched script to ensure that the code is never loaded if the source has been manipulated
|Specifies that the script should not be executed in browsers supporting ES2015 modules.
|A cryptographic nonce (number used once) to allow scripts in a script-src Content-Security-Policy. The server must generate a unique nonce value each time it transmits a policy. It is critical to provide a nonce that cannot be guessed as bypassing a resource's policy is otherwise trivial.
|Specifies which referrer information to send when fetching a script
|The URL to an external file that contains the source code or data.
|Sets or retrieves the script’s character encoding. You can’t use the type attribute with this attribute.
|The programming language for the associated scripting engine. Depracated, use type instead.
|Specifies whether whitespace should be preserved within the script element.
The <script> element also supports the Global Attributes in HTML.
The <script> element also supports the Event Attributes in HTML.
By Default CSS Value(s)
Most of the browsers will display the <script> element with the following by default value(s)