← Back to release summary

HTMLScriptElement.supports(type) method

Category
JavaScript
Type
New or changed feature
Status
Enabled by default (Chrome 97)
Intent stage
Shipped

Summary

Provides a unified way to detect new features that use script elements.

Motivation

Currently there is no simple way to know what kind of types can be used for HTMLScriptElement’s type attribute. There are several new feature proposals using the script element. https://github.com/WICG/import-maps/ https://github.com/jeremyroman/alternate-loading-modes/blob/main/triggers.md#speculation-rules https://github.com/WICG/resource-bundles/ We can use the nomodule attribute to detect the module type support. But there is no unified method to detect such new features. If we have the HTMLScriptElement.supports(type) method which is like HTMLLinkElement.relList.supports(), we can easily detect such features.

Standards & signals

Docs: https://github.com/horo-t/explainers/blob/main/script_element_supports.md

Samples: https://horo-t.github.io/explainers/script_element_supports_sample.html

Explainers: https://github.com/horo-t/explainers/blob/main/script_element_supports.md

View on chromestatus.com