coderef

<script> and <noscript>Baseline · Widely available

The &#x3C;script> element contains or loads data or executable code. This is typically used to load JavaScript code. The &#x3C;noscript> element represents alternative content to show when scripting is not allowed.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jul 29, 2015. Widely available since Jan 29, 2018.

Browser support

DesktopChrome
1+Supportedsince Dec 11, 2008
Current: 155
Edge
12+Supportedsince Jul 29, 2015
Current: 154
Firefox
1+Supportedsince Nov 9, 2004
Current: 157
Safari
1–2Not supported
3+Supportedsince Oct 26, 2007
Current: 27
MobileChrome Android
18+Supportedsince Jun 27, 2012
Current: 155
Firefox Android
4+Supportedsince Mar 29, 2011
Current: 157
Safari iOS
1–1Not supported
2+Supportedsince Jul 11, 2008
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: HTMLScriptElement.

Feature detection

JS · check before using
const el = document.createElement("script");
if (!(el instanceof HTMLUnknownElement)) {
  // <script> is supported
}

Sub-features

Support for each part of the feature (17). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
HTMLScriptElement112131841
HTMLScriptElement.async6123.65.11845
HTMLScriptElement.crossOrigin191414625146
HTMLScriptElement.defer1123.531841
HTMLScriptElement.innerText11245318452
HTMLScriptElement.src112131841
HTMLScriptElement.supports_static96969416969416
HTMLScriptElement.text112131841
HTMLScriptElement.textContent112131841
HTMLScriptElement.type112131841
noscript112131842
script112131842
script.async1123.6≤4184≤3.2
script.crossorigin191414625146
script.defer1123.531842
script.src1121≤4184≤3.2
script.type1121≤4184≤3.2