HTML <script> Tag
The Script element is used to embed or refer to a client-side script like JavaScript.
This tag is sometimes referred to as the <script>
element. The script tag is used to incorporate a client-side script (JavaScript).
The <script>
element either includes scripting statements or, via the src property, connects to an external script file.
JavaScript is commonly used for image modification, form validation, and dynamic content updates.
Syntax
Attributes
Attribute | Value | Description |
---|---|---|
async | async | Specifies that the script be downloaded concurrently with page processing and run as soon as it is available. |
crossorigin |
anonymous
use-credentials |
Sets the request mode to HTTP CORS Request. |
defer | defer | Specifies that the script is downloaded concurrently with page processing and run after the page has finished parsing. |
integrity | filehash | Allows a browser to validate the retrieved script, ensuring that the code is never loaded if the source has been tampered with. |
nomodule |
True
False |
This specifies that the script should not be run in browsers that support ES2015 modules. |
referrerpolicy |
no-referrer
no-referrer-when-downgrade origin origin-when-cross-origin same-origin strict-origin strict-origin-when-cross-origin unsafe-url |
When requesting a script, this property specifies the referrer information to deliver. |
src | URL | The URL of an external script file is specified. |
type | scripttype | Specifies the script's media type. |
Supported Browsers
Element | Chrome | Firefox | Safari | Edge / IE | Opera |
---|---|---|---|---|---|
<script> | Yes | Yes | Yes | Yes | Yes |