| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/en-US/docs/Web/API/HTMLScriptElement/supports_static | [Back] [Original] |
Get to know MDN better
This feature is well established and works across many devices and browser versions. Its been available across browsers since September 2022.
The supports() static method of the HTMLScriptElement interface provides a simple and consistent method to feature-detect what types of scripts are supported by the user agent.
The method is expected to return true for classic and module scripts, which are supported by most modern browsers.
HTMLScriptElement.supports(type)
typeA string literal that indicates the type of script for which support is to be checked. Supported values are case sensitive, and include:
"classic"Test if classic scripts are supported. "Classic" scripts are the normal/traditional JavaScript files that predate module scripts.
"module"Test if module scripts are supported.
"importmap"Test if import maps are supported.
"speculationrules"Test if speculation rules are supported and enabled.
Any other value will cause the method to return false.
Returns true if the indicated script type is supported and false otherwise.
The code below shows how to check if HTMLScriptElement.supports() is defined, and if so, to use it to test whether particular types of scripts are supported.
const log = document.getElementById("log");
function checkSupport(type) {
const result = HTMLScriptElement.supports(type) ? "true" : "false";
log.textContent += `HTMLScriptElement.supports('${type}') is ${result}\n`;
}
if (typeof HTMLScriptElement.supports === "undefined") {
log.textContent = "HTMLScriptElement.supports() method is not supported";
} else {
// Check if various script types are supported
checkSupport("module");
checkSupport("classic");
checkSupport("importmap");
checkSupport("speculationrules");
// Any other value will cause the method to return false
checkSupport("anything else");
}
<textarea id="log" rows="6" cols="80"></textarea>
| Specification |
|---|
| HTML # dom-script-supports-dev |
HTMLScriptElement<script>Worker constructorThis page was last modified on Jun 23, 2025 by MDN contributors.
HTMLScriptElementBeforeUnloadEventDOMStringMapErrorEventHTMLAnchorElementHTMLAreaElementHTMLAudioElementHTMLBRElementHTMLBaseElementHTMLBodyElementHTMLButtonElementHTMLCanvasElementHTMLDListElementHTMLDataElementHTMLDataListElementHTMLDialogElementHTMLDivElementHTMLDocumentHTMLElementHTMLEmbedElementHTMLFieldSetElementHTMLFormControlsCollectionHTMLFormElementHTMLFrameSetElementHTMLGeolocationElementHTMLHRElementHTMLHeadElementHTMLHeadingElementHTMLHtmlElementHTMLIFrameElementHTMLImageElementHTMLInputElementHTMLLIElementHTMLLabelElementHTMLLegendElementHTMLLinkElementHTMLMapElementHTMLMediaElementHTMLMenuElementHTMLMetaElementHTMLMeterElementHTMLModElementHTMLOListElementHTMLObjectElementHTMLOptGroupElementHTMLOptionElementHTMLOptionsCollectionHTMLOutputElementHTMLParagraphElementHTMLPictureElementHTMLPreElementHTMLProgressElementHTMLQuoteElementHTMLSelectElementHTMLSourceElementHTMLSpanElementHTMLStyleElementHTMLTableCaptionElementHTMLTableCellElementHTMLTableColElementHTMLTableElementHTMLTableRowElementHTMLTableSectionElementHTMLTemplateElementHTMLTextAreaElementHTMLTimeElementHTMLTitleElementHTMLTrackElementHTMLUListElementHTMLUnknownElementHTMLVideoElementHashChangeEventHistoryImageDataLocationMessageChannelMessageEventMessagePortNavigatorPageRevealEventPageSwapEventPageTransitionEventPluginPluginArrayPromiseRejectionEventRadioNodeListTimeRangesUserActivationValidityStateWindowWorkletGlobalScopeYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |