Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lili21/47b3e5989daea0dfea9468471a0fc5df to your computer and use it in GitHub Desktop.
Save lili21/47b3e5989daea0dfea9468471a0fc5df to your computer and use it in GitHub Desktop.
DOMTokenList supports() example for Preload
var DOMTokenListSupports = function(tokenList, token) {
if (!tokenList || !tokenList.supports) {
return;
}
try {
return tokenList.supports(token);
} catch (e) {
if (e instanceof TypeError) {
console.log("The DOMTokenList doesn't have a supported tokens list");
} else {
console.error("That shouldn't have happened");
}
}
};
// test if preload is supported
var linkSupportsPreload = DOMTokenListSupports(document.createElement("link").relList, "preload");
if (linkSupportsPreload) {
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment