Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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) {
// ...
}
@safareli

This comment has been minimized.

Show comment
Hide comment
@safareli

safareli Jun 26, 2018

on IE relList is not supported https://caniuse.com/#search=relList so you this only works on modern browsers which already support preload https://caniuse.com/#search=preload

on IE relList is not supported https://caniuse.com/#search=relList so you this only works on modern browsers which already support preload https://caniuse.com/#search=preload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment