Skip to content

Commit

Permalink
Feat(w3c/style): Generalize opportunistic preload/preconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres committed Jun 23, 2016
1 parent 5513932 commit e3b62d9
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions js/w3c/style.js
Expand Up @@ -48,19 +48,25 @@ define(
return version;
}

// Opportunistically preconnect to w3c server for styles and script
var preconnectLink = document.createElement("link");
preconnectLink.rel = "preconnect";
preconnectLink.href = "https://www.w3.org";
preconnectLink.crossorigin = true;
document.head.appendChild(preconnectLink);
// Opportunistically preconnect to w3c server for styles and scripts
var preconnectW3C = utils.createResourceHint({
hint: "preconnect",
href: "https://www.w3.org",
});
document.head.appendChild(preconnectW3C);

// Opportunistically preload fixup, as we attach it on end-all
var preloadLink = document.createElement("link");
preloadLink.rel = "preload";
preloadLink.href = "https://www.w3.org/scripts/TR/2016/fixup.js"
preloadLink.as = "script";
document.head.appendChild(preloadLink);
// Opportunistically preload fixup.js, as we attach it on end-all
var preloadFixupjs = utils.createResourceHint({
hint: "preload",
href: "https://www.w3.org/scripts/TR/2016/fixup.js",
as: "script",
});
document.head.appendChild(preloadFixupjs);

// Attach meta viewport, as needed
if (!document.head.querySelector("meta[name=viewport]")) {
attachMetaViewport(document);
}

return {
run: function(conf, doc, cb) {
Expand Down Expand Up @@ -108,11 +114,6 @@ define(
// Select between released styles and experimental style.
var version = selectStyleVersion(conf.useExperimentalStyles || "2016");

// Make spec mobile friendly by attaching meta viewport
if (!doc.head.querySelector("meta[name=viewport]")) {
attachMetaViewport(doc);
}

// Attach W3C fixup script after we are done.
if (version) {
var subscribeKey = pubsubhub.sub("end-all", function (){
Expand Down

0 comments on commit e3b62d9

Please sign in to comment.