Skip to content

Instantly share code, notes, and snippets.

@yoavweiss
Last active July 24, 2020 19:31
Show Gist options
  • Select an option

  • Save yoavweiss/b1f798bb2be4e671107b to your computer and use it in GitHub Desktop.

Select an option

Save yoavweiss/b1f798bb2be4e671107b to your computer and use it in GitHub Desktop.

Revisions

  1. yoavweiss revised this gist Feb 16, 2016. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions preload_feature_detection.js
    Original file line number Diff line number Diff line change
    @@ -16,5 +16,4 @@ var DOMTokenListSupports = function(tokenList, token) {
    var linkSupportsPreload = DOMTokenListSupports(document.createElement("link").relList, "preload");
    if (!linkSupportsPreload) {
    // Dynamically load the things that relied on preload.
    }
    }
    }
  2. yoavweiss created this gist Feb 16, 2016.
    20 changes: 20 additions & 0 deletions preload_feature_detection.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    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");
    }
    }
    };

    var linkSupportsPreload = DOMTokenListSupports(document.createElement("link").relList, "preload");
    if (!linkSupportsPreload) {
    // Dynamically load the things that relied on preload.
    }
    }