-
Notifications
You must be signed in to change notification settings - Fork 26k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize Prefetching #9818
Merged
Merged
Optimize Prefetching #9818
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Stats from current PRDefault Server Mode (Decrease detected ✓)General Overall decrease ✓
Client Bundles (main, webpack, commons) Overall decrease ✓
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
Legacy Client Bundles (polyfills)
Client Pages
Client Pages Modern
Client Build Manifests
Rendered Page Sizes
DiffsDiff for main-HASH.js@@ -437,7 +437,7 @@ if (!window.Promise) {
var data = JSON.parse(document.getElementById('__NEXT_DATA__').textContent);
window.__NEXT_DATA__ = data;
-var version = "9.1.7-canary.3";
+var version = "9.1.7-canary.2";
exports.version = version;
var props = data.props,
err = data.err,
@@ -1390,32 +1390,28 @@ var _mitt = _interopRequireDefault(__webpack_require__("dZ6Y"));
/* global document, window */
-var prefetchOrPreload = undefined ? 'prefetch' : 'preload';
-
-function supportsPreload(el) {
+function hasPrefetch(link) {
try {
- return el.relList.supports(prefetchOrPreload);
+ link = document.createElement('link');
+ return link.relList.supports('prefetch');
} catch (_unused) {
return false;
}
}
-var hasPreload = supportsPreload(document.createElement('link'));
+var relPrefetch = hasPrefetch() ? // https://caniuse.com/#feat=link-rel-prefetch
+// IE 11, Edge 12+, nearly all evergreen
+'prefetch' : // https://caniuse.com/#feat=link-rel-preload
+// macOS and iOS (Safari does not support prefetch)
+'preload';
+var hasNoModule = 'noModule' in document.createElement('script');
-function preloadLink(url, resourceType) {
+function appendLink(href, rel, as) {
var link = document.createElement('link');
- link.rel = prefetchOrPreload;
link.crossOrigin = "anonymous";
- link.href = url;
- link.as = resourceType;
- document.head.appendChild(link);
-}
-
-function loadStyle(url) {
- var link = document.createElement('link');
- link.rel = 'stylesheet';
- link.crossOrigin = "anonymous";
- link.href = url;
+ link.href = href;
+ link.rel = rel;
+ if (as) link.as = as;
document.head.appendChild(link);
}
@@ -1476,7 +1472,7 @@ function () {
}, {
key: "loadPageScript",
value: function loadPageScript(route) {
- var _this3 = this;
+ var _this2 = this;
route = this.normalizeRoute(route);
return new _promise["default"](function (resolve, reject) {
@@ -1485,9 +1481,9 @@ function () {
page = _ref.page,
mod = _ref.mod;
- _this3.pageRegisterEvents.off(route, fire);
+ _this2.pageRegisterEvents.off(route, fire);
- delete _this3.loadingRoutes[route];
+ delete _this2.loadingRoutes[route];
if (error) {
reject(error);
@@ -1500,7 +1496,7 @@ function () {
}; // If there's a cached version of the page, let's use it.
- var cachedPage = _this3.pageCache[route];
+ var cachedPage = _this2.pageCache[route];
if (cachedPage) {
var error = cachedPage.error,
@@ -1514,7 +1510,7 @@ function () {
} // Register a listener to get the page
- _this3.pageRegisterEvents.on(route, fire); // If the page is loading via SSR, we need to wait for it
+ _this2.pageRegisterEvents.on(route, fire); // If the page is loading via SSR, we need to wait for it
// rather downloading it again.
@@ -1522,22 +1518,22 @@ function () {
return;
}
- if (!_this3.loadingRoutes[route]) {
+ if (!_this2.loadingRoutes[route]) {
if (true) {
- _this3.getDependencies(route).then(function (deps) {
+ _this2.getDependencies(route).then(function (deps) {
deps.forEach(function (d) {
if (/\.js$/.test(d) && !document.querySelector("script[src^=\"" + d + "\"]")) {
- _this3.loadScript(d, route, false);
+ _this2.loadScript(d, route, false);
}
if (/\.css$/.test(d) && !document.querySelector("link[rel=stylesheet][href^=\"" + d + "\"]")) {
- loadStyle(d); // FIXME: handle failure
+ appendLink(d, 'stylesheet'); // FIXME: handle failure
}
});
- _this3.loadRoute(route);
+ _this2.loadRoute(route);
- _this3.loadingRoutes[route] = true;
+ _this2.loadingRoutes[route] = true;
});
} else {}
}
@@ -1573,11 +1569,11 @@ function () {
}, {
key: "loadScript",
value: function loadScript(url, route, isPage) {
- var _this4 = this;
+ var _this3 = this;
var script = document.createElement('script');
- if ( true && 'noModule' in script) {
+ if ( true && hasNoModule) {
script.type = 'module'; // Only page bundle scripts need to have .module added to url,
// dependencies already have it added during build manifest creation
@@ -1591,7 +1587,7 @@ function () {
var error = new Error("Error loading script " + url);
error.code = 'PAGE_LOAD_ERROR';
- _this4.pageRegisterEvents.emit(route, {
+ _this3.pageRegisterEvents.emit(route, {
error: error
});
};
@@ -1602,7 +1598,7 @@ function () {
}, {
key: "registerPage",
value: function registerPage(route, regFn) {
- var _this5 = this;
+ var _this4 = this;
var register = function register() {
try {
@@ -1611,15 +1607,15 @@ function () {
page: mod["default"] || mod,
mod: mod
};
- _this5.pageCache[route] = pageData;
+ _this4.pageCache[route] = pageData;
- _this5.pageRegisterEvents.emit(route, pageData);
+ _this4.pageRegisterEvents.emit(route, pageData);
} catch (error) {
- _this5.pageCache[route] = {
+ _this4.pageCache[route] = {
error: error
};
- _this5.pageRegisterEvents.emit(route, {
+ _this4.pageRegisterEvents.emit(route, {
error: error
});
}
@@ -1632,108 +1628,46 @@ function () {
}, {
key: "prefetch",
value: function prefetch(route, isDependency) {
- var _this2 = this;
-
- return (0, _asyncToGenerator2["default"])(
- /*#__PURE__*/
- _regeneratorRuntime.mark(function _callee2() {
- var scriptRoute, url, cn;
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- route = _this2.normalizeRoute(route);
- scriptRoute = (route === '/' ? '/index' : route) + ".js";
-
- if ( true && 'noModule' in document.createElement('script')) {
- scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
- }
-
- url = _this2.assetPrefix + (isDependency ? route : "/_next/static/" + encodeURIComponent(_this2.buildId) + "/pages" + encodeURI(scriptRoute)); // n.b. If preload is not supported, we fall back to `loadPage` which has
- // its own deduping mechanism.
-
- if (!(_this2.prefetched[route] || document.querySelector("link[rel=\"" + prefetchOrPreload + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]"))) {
- _context2.next = 6;
- break;
- }
-
- return _context2.abrupt("return");
-
- case 6:
- _this2.prefetched[route] = true; // Inspired by quicklink, license: https://github.com/GoogleChromeLabs/quicklink/blob/master/LICENSE
-
- if (!(cn = navigator.connection)) {
- _context2.next = 10;
- break;
- }
-
- if (!((cn.effectiveType || '').indexOf('2g') !== -1 || cn.saveData)) {
- _context2.next = 10;
- break;
- }
-
- return _context2.abrupt("return");
-
- case 10:
- if (!( true && !isDependency)) {
- _context2.next = 16;
- break;
- }
-
- ;
- _context2.next = 14;
- return _this2.getDependencies(route);
-
- case 14:
- _context2.t0 = function (url) {
- _this2.prefetch(url, true);
- };
+ var _this5 = this;
- _context2.sent.forEach(_context2.t0);
+ // https://github.com/GoogleChromeLabs/quicklink/blob/453a661fa1fa940e2d2e044452398e38c67a98fb/src/index.mjs#L115-L118
+ // License: Apache 2.0
+ var cn;
- case 16:
- if (!hasPreload) {
- _context2.next = 19;
- break;
- }
+ if (cn = navigator.connection) {
+ // Don't prefetch if using 2G or if Save-Data is enabled.
+ if (cn.saveData || /2g/.test(cn.effectiveType)) return;
+ }
- preloadLink(url, url.match(/\.css$/) ? 'style' : 'script');
- return _context2.abrupt("return");
+ var url = this.assetPrefix;
- case 19:
- if (!isDependency) {
- _context2.next = 21;
- break;
- }
+ if (isDependency) {
+ url += route;
+ } else {
+ route = this.normalizeRoute(route);
+ this.prefetched[route] = true;
+ var scriptRoute = (route === '/' ? '/index' : route) + ".js";
- return _context2.abrupt("return");
+ if ( true && hasNoModule) {
+ scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
+ }
- case 21:
- if (!(document.readyState === 'complete')) {
- _context2.next = 25;
- break;
- }
+ url += "/_next/static/" + encodeURIComponent(this.buildId) + "/pages" + encodeURI(scriptRoute);
+ }
- return _context2.abrupt("return", _this2.loadPage(route)["catch"](function () {}));
+ if (document.querySelector("link[rel=\"" + relPrefetch + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
+ return;
+ }
- case 25:
- return _context2.abrupt("return", new _promise["default"](function (resolve) {
- window.addEventListener('load', function () {
- _this2.loadPage(route).then(function () {
- return resolve();
- }, function () {
- return resolve();
- });
- });
- }));
+ appendLink(url, relPrefetch, url.match(/\.css$/) ? 'style' : 'script');
- case 26:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- }))();
+ if ( true && !isDependency) {
+ this.getDependencies(route).then(function (urls) {
+ return urls.forEach(function (url) {
+ _this5.prefetch(url, true);
+ });
+ });
+ }
}
}]); Diff for main-HASH.module.js@@ -341,7 +341,7 @@ if (!window.Promise) {
var data = JSON.parse(document.getElementById('__NEXT_DATA__').textContent);
window.__NEXT_DATA__ = data;
-var version = "9.1.7-canary.3";
+var version = "9.1.7-canary.2";
exports.version = version;
var {
props,
@@ -1081,32 +1081,28 @@ var _mitt = _interopRequireDefault(__webpack_require__("dZ6Y"));
/* global document, window */
-var prefetchOrPreload = undefined ? 'prefetch' : 'preload';
-
-function supportsPreload(el) {
+function hasPrefetch(link) {
try {
- return el.relList.supports(prefetchOrPreload);
+ link = document.createElement('link');
+ return link.relList.supports('prefetch');
} catch (_unused) {
return false;
}
}
-var hasPreload = supportsPreload(document.createElement('link'));
+var relPrefetch = hasPrefetch() ? // https://caniuse.com/#feat=link-rel-prefetch
+// IE 11, Edge 12+, nearly all evergreen
+'prefetch' : // https://caniuse.com/#feat=link-rel-preload
+// macOS and iOS (Safari does not support prefetch)
+'preload';
+var hasNoModule = 'noModule' in document.createElement('script');
-function preloadLink(url, resourceType) {
+function appendLink(href, rel, as) {
var link = document.createElement('link');
- link.rel = prefetchOrPreload;
link.crossOrigin = "anonymous";
- link.href = url;
- link.as = resourceType;
- document.head.appendChild(link);
-}
-
-function loadStyle(url) {
- var link = document.createElement('link');
- link.rel = 'stylesheet';
- link.crossOrigin = "anonymous";
- link.href = url;
+ link.href = href;
+ link.rel = rel;
+ if (as) link.as = as;
document.head.appendChild(link);
}
@@ -1206,7 +1202,7 @@ class PageLoader {
}
if (/\.css$/.test(d) && !document.querySelector("link[rel=stylesheet][href^=\"" + d + "\"]")) {
- loadStyle(d); // FIXME: handle failure
+ appendLink(d, 'stylesheet'); // FIXME: handle failure
}
});
this.loadRoute(route);
@@ -1232,7 +1228,7 @@ class PageLoader {
loadScript(url, route, isPage) {
var script = document.createElement('script');
- if ( true && 'noModule' in script) {
+ if ( true && hasNoModule) {
script.type = 'module'; // Only page bundle scripts need to have .module added to url,
// dependencies already have it added during build manifest creation
@@ -1280,65 +1276,42 @@ class PageLoader {
}
prefetch(route, isDependency) {
- var _this2 = this;
-
- return (0, _asyncToGenerator2.default)(function* () {
- route = _this2.normalizeRoute(route);
- var scriptRoute = (route === '/' ? '/index' : route) + ".js";
+ // https://github.com/GoogleChromeLabs/quicklink/blob/453a661fa1fa940e2d2e044452398e38c67a98fb/src/index.mjs#L115-L118
+ // License: Apache 2.0
+ var cn;
- if ( true && 'noModule' in document.createElement('script')) {
- scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
- }
-
- var url = _this2.assetPrefix + (isDependency ? route : "/_next/static/" + encodeURIComponent(_this2.buildId) + "/pages" + encodeURI(scriptRoute)); // n.b. If preload is not supported, we fall back to `loadPage` which has
- // its own deduping mechanism.
-
- if (_this2.prefetched[route] || document.querySelector("link[rel=\"" + prefetchOrPreload + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
- return;
- }
+ if (cn = navigator.connection) {
+ // Don't prefetch if using 2G or if Save-Data is enabled.
+ if (cn.saveData || /2g/.test(cn.effectiveType)) return;
+ }
- _this2.prefetched[route] = true; // Inspired by quicklink, license: https://github.com/GoogleChromeLabs/quicklink/blob/master/LICENSE
+ var url = this.assetPrefix;
- var cn;
+ if (isDependency) {
+ url += route;
+ } else {
+ route = this.normalizeRoute(route);
+ this.prefetched[route] = true;
+ var scriptRoute = (route === '/' ? '/index' : route) + ".js";
- if (cn = navigator.connection) {
- // Don't prefetch if the user is on 2G or if Save-Data is enabled.
- if ((cn.effectiveType || '').indexOf('2g') !== -1 || cn.saveData) {
- return;
- }
+ if ( true && hasNoModule) {
+ scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
}
- if ( true && !isDependency) {
- ;
- (yield _this2.getDependencies(route)).forEach(url => {
- _this2.prefetch(url, true);
- });
- } // Feature detection is used to see if preload is supported
- // If not fall back to loading script tags before the page is loaded
- // https://caniuse.com/#feat=link-rel-preload
+ url += "/_next/static/" + encodeURIComponent(this.buildId) + "/pages" + encodeURI(scriptRoute);
+ }
+ if (document.querySelector("link[rel=\"" + relPrefetch + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
+ return;
+ }
- if (hasPreload) {
- preloadLink(url, url.match(/\.css$/) ? 'style' : 'script');
- return;
- }
+ appendLink(url, relPrefetch, url.match(/\.css$/) ? 'style' : 'script');
- if (isDependency) {
- // loadPage will automatically handle dependencies, so no need to
- // preload them manually
- return;
- }
-
- if (document.readyState === 'complete') {
- return _this2.loadPage(route).catch(() => {});
- } else {
- return new _promise.default(resolve => {
- window.addEventListener('load', () => {
- _this2.loadPage(route).then(() => resolve(), () => resolve());
- });
- });
- }
- })();
+ if ( true && !isDependency) {
+ this.getDependencies(route).then(urls => urls.forEach(url => {
+ this.prefetch(url, true);
+ }));
+ }
}
} Diff for index.html@@ -12,7 +12,7 @@
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/runtime/webpack-7928590be3ef2e55b835.module.js"
as="script" crossorigin="anonymous" />
- <link rel="preload" href="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/chunks/framework.9c9aa574c484a7d0240e.module.js"
as="script" crossorigin="anonymous" />
@@ -44,9 +44,9 @@
async="" crossorigin="anonymous" nomodule=""></script>
<script src="/_next/static/runtime/webpack-7928590be3ef2e55b835.module.js"
async="" crossorigin="anonymous" type="module"></script>
- <script src="/_next/static/runtime/main-c7894c8b919067f5cc96.js"
+ <script src="/_next/static/runtime/main-61c9f5a18beee988f275.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <script src="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
async="" crossorigin="anonymous" type="module"></script>
<script src="/_next/static/chunks/framework.4c64484d8a631a55b435.js"
async="" crossorigin="anonymous" nomodule=""></script> Diff for link.html@@ -18,7 +18,7 @@
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
as="script" crossorigin="anonymous" />
- <link rel="preload" href="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
as="script" crossorigin="anonymous" />
</head>
@@ -61,9 +61,9 @@
async="" crossorigin="anonymous" nomodule=""></script>
<script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
async="" crossorigin="anonymous" type="module"></script>
- <script src="/_next/static/runtime/main-c7894c8b919067f5cc96.js"
+ <script src="/_next/static/runtime/main-61c9f5a18beee988f275.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <script src="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
async="" crossorigin="anonymous" type="module"></script>
<script src="/_next/static/BUILD_ID/_buildManifest.js" async=""
crossorigin="anonymous" nomodule=""></script> Diff for withRouter.html@@ -18,7 +18,7 @@
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
as="script" crossorigin="anonymous" />
- <link rel="preload" href="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
as="script" crossorigin="anonymous" />
</head>
@@ -59,9 +59,9 @@
async="" crossorigin="anonymous" nomodule=""></script>
<script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
async="" crossorigin="anonymous" type="module"></script>
- <script src="/_next/static/runtime/main-c7894c8b919067f5cc96.js"
+ <script src="/_next/static/runtime/main-61c9f5a18beee988f275.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <script src="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
async="" crossorigin="anonymous" type="module"></script>
<script src="/_next/static/BUILD_ID/_buildManifest.js" async=""
crossorigin="anonymous" nomodule=""></script> Serverless Mode (Decrease detected ✓)General Overall decrease ✓
Client Bundles (main, webpack, commons) Overall decrease ✓
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
Legacy Client Bundles (polyfills)
Client Pages
Client Pages Modern
Client Build Manifests
Serverless bundles Overall decrease ✓
Commit: d5349b5 |
Stats from current PRDefault Server Mode (Decrease detected ✓)General Overall decrease ✓
Client Bundles (main, webpack, commons) Overall decrease ✓
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
Legacy Client Bundles (polyfills)
Client Pages
Client Pages Modern
Client Build Manifests
Rendered Page Sizes
DiffsDiff for main-HASH.js@@ -437,7 +437,7 @@ if (!window.Promise) {
var data = JSON.parse(document.getElementById('__NEXT_DATA__').textContent);
window.__NEXT_DATA__ = data;
-var version = "9.1.7-canary.3";
+var version = "9.1.7-canary.2";
exports.version = version;
var props = data.props,
err = data.err,
@@ -1390,32 +1390,28 @@ var _mitt = _interopRequireDefault(__webpack_require__("dZ6Y"));
/* global document, window */
-var prefetchOrPreload = undefined ? 'prefetch' : 'preload';
-
-function supportsPreload(el) {
+function hasPrefetch(link) {
try {
- return el.relList.supports(prefetchOrPreload);
+ link = document.createElement('link');
+ return link.relList.supports('prefetch');
} catch (_unused) {
return false;
}
}
-var hasPreload = supportsPreload(document.createElement('link'));
+var relPrefetch = hasPrefetch() ? // https://caniuse.com/#feat=link-rel-prefetch
+// IE 11, Edge 12+, nearly all evergreen
+'prefetch' : // https://caniuse.com/#feat=link-rel-preload
+// macOS and iOS (Safari does not support prefetch)
+'preload';
+var hasNoModule = 'noModule' in document.createElement('script');
-function preloadLink(url, resourceType) {
+function appendLink(href, rel, as) {
var link = document.createElement('link');
- link.rel = prefetchOrPreload;
link.crossOrigin = "anonymous";
- link.href = url;
- link.as = resourceType;
- document.head.appendChild(link);
-}
-
-function loadStyle(url) {
- var link = document.createElement('link');
- link.rel = 'stylesheet';
- link.crossOrigin = "anonymous";
- link.href = url;
+ link.href = href;
+ link.rel = rel;
+ if (as) link.as = as;
document.head.appendChild(link);
}
@@ -1476,7 +1472,7 @@ function () {
}, {
key: "loadPageScript",
value: function loadPageScript(route) {
- var _this3 = this;
+ var _this2 = this;
route = this.normalizeRoute(route);
return new _promise["default"](function (resolve, reject) {
@@ -1485,9 +1481,9 @@ function () {
page = _ref.page,
mod = _ref.mod;
- _this3.pageRegisterEvents.off(route, fire);
+ _this2.pageRegisterEvents.off(route, fire);
- delete _this3.loadingRoutes[route];
+ delete _this2.loadingRoutes[route];
if (error) {
reject(error);
@@ -1500,7 +1496,7 @@ function () {
}; // If there's a cached version of the page, let's use it.
- var cachedPage = _this3.pageCache[route];
+ var cachedPage = _this2.pageCache[route];
if (cachedPage) {
var error = cachedPage.error,
@@ -1514,7 +1510,7 @@ function () {
} // Register a listener to get the page
- _this3.pageRegisterEvents.on(route, fire); // If the page is loading via SSR, we need to wait for it
+ _this2.pageRegisterEvents.on(route, fire); // If the page is loading via SSR, we need to wait for it
// rather downloading it again.
@@ -1522,22 +1518,22 @@ function () {
return;
}
- if (!_this3.loadingRoutes[route]) {
+ if (!_this2.loadingRoutes[route]) {
if (true) {
- _this3.getDependencies(route).then(function (deps) {
+ _this2.getDependencies(route).then(function (deps) {
deps.forEach(function (d) {
if (/\.js$/.test(d) && !document.querySelector("script[src^=\"" + d + "\"]")) {
- _this3.loadScript(d, route, false);
+ _this2.loadScript(d, route, false);
}
if (/\.css$/.test(d) && !document.querySelector("link[rel=stylesheet][href^=\"" + d + "\"]")) {
- loadStyle(d); // FIXME: handle failure
+ appendLink(d, 'stylesheet'); // FIXME: handle failure
}
});
- _this3.loadRoute(route);
+ _this2.loadRoute(route);
- _this3.loadingRoutes[route] = true;
+ _this2.loadingRoutes[route] = true;
});
} else {}
}
@@ -1573,11 +1569,11 @@ function () {
}, {
key: "loadScript",
value: function loadScript(url, route, isPage) {
- var _this4 = this;
+ var _this3 = this;
var script = document.createElement('script');
- if ( true && 'noModule' in script) {
+ if ( true && hasNoModule) {
script.type = 'module'; // Only page bundle scripts need to have .module added to url,
// dependencies already have it added during build manifest creation
@@ -1591,7 +1587,7 @@ function () {
var error = new Error("Error loading script " + url);
error.code = 'PAGE_LOAD_ERROR';
- _this4.pageRegisterEvents.emit(route, {
+ _this3.pageRegisterEvents.emit(route, {
error: error
});
};
@@ -1602,7 +1598,7 @@ function () {
}, {
key: "registerPage",
value: function registerPage(route, regFn) {
- var _this5 = this;
+ var _this4 = this;
var register = function register() {
try {
@@ -1611,15 +1607,15 @@ function () {
page: mod["default"] || mod,
mod: mod
};
- _this5.pageCache[route] = pageData;
+ _this4.pageCache[route] = pageData;
- _this5.pageRegisterEvents.emit(route, pageData);
+ _this4.pageRegisterEvents.emit(route, pageData);
} catch (error) {
- _this5.pageCache[route] = {
+ _this4.pageCache[route] = {
error: error
};
- _this5.pageRegisterEvents.emit(route, {
+ _this4.pageRegisterEvents.emit(route, {
error: error
});
}
@@ -1632,108 +1628,46 @@ function () {
}, {
key: "prefetch",
value: function prefetch(route, isDependency) {
- var _this2 = this;
-
- return (0, _asyncToGenerator2["default"])(
- /*#__PURE__*/
- _regeneratorRuntime.mark(function _callee2() {
- var scriptRoute, url, cn;
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- route = _this2.normalizeRoute(route);
- scriptRoute = (route === '/' ? '/index' : route) + ".js";
-
- if ( true && 'noModule' in document.createElement('script')) {
- scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
- }
-
- url = _this2.assetPrefix + (isDependency ? route : "/_next/static/" + encodeURIComponent(_this2.buildId) + "/pages" + encodeURI(scriptRoute)); // n.b. If preload is not supported, we fall back to `loadPage` which has
- // its own deduping mechanism.
-
- if (!(_this2.prefetched[route] || document.querySelector("link[rel=\"" + prefetchOrPreload + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]"))) {
- _context2.next = 6;
- break;
- }
-
- return _context2.abrupt("return");
-
- case 6:
- _this2.prefetched[route] = true; // Inspired by quicklink, license: https://github.com/GoogleChromeLabs/quicklink/blob/master/LICENSE
-
- if (!(cn = navigator.connection)) {
- _context2.next = 10;
- break;
- }
-
- if (!((cn.effectiveType || '').indexOf('2g') !== -1 || cn.saveData)) {
- _context2.next = 10;
- break;
- }
-
- return _context2.abrupt("return");
-
- case 10:
- if (!( true && !isDependency)) {
- _context2.next = 16;
- break;
- }
-
- ;
- _context2.next = 14;
- return _this2.getDependencies(route);
-
- case 14:
- _context2.t0 = function (url) {
- _this2.prefetch(url, true);
- };
+ var _this5 = this;
- _context2.sent.forEach(_context2.t0);
+ // https://github.com/GoogleChromeLabs/quicklink/blob/453a661fa1fa940e2d2e044452398e38c67a98fb/src/index.mjs#L115-L118
+ // License: Apache 2.0
+ var cn;
- case 16:
- if (!hasPreload) {
- _context2.next = 19;
- break;
- }
+ if (cn = navigator.connection) {
+ // Don't prefetch if using 2G or if Save-Data is enabled.
+ if (cn.saveData || /2g/.test(cn.effectiveType)) return;
+ }
- preloadLink(url, url.match(/\.css$/) ? 'style' : 'script');
- return _context2.abrupt("return");
+ var url = this.assetPrefix;
- case 19:
- if (!isDependency) {
- _context2.next = 21;
- break;
- }
+ if (isDependency) {
+ url += route;
+ } else {
+ route = this.normalizeRoute(route);
+ this.prefetched[route] = true;
+ var scriptRoute = (route === '/' ? '/index' : route) + ".js";
- return _context2.abrupt("return");
+ if ( true && hasNoModule) {
+ scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
+ }
- case 21:
- if (!(document.readyState === 'complete')) {
- _context2.next = 25;
- break;
- }
+ url += "/_next/static/" + encodeURIComponent(this.buildId) + "/pages" + encodeURI(scriptRoute);
+ }
- return _context2.abrupt("return", _this2.loadPage(route)["catch"](function () {}));
+ if (document.querySelector("link[rel=\"" + relPrefetch + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
+ return;
+ }
- case 25:
- return _context2.abrupt("return", new _promise["default"](function (resolve) {
- window.addEventListener('load', function () {
- _this2.loadPage(route).then(function () {
- return resolve();
- }, function () {
- return resolve();
- });
- });
- }));
+ appendLink(url, relPrefetch, url.match(/\.css$/) ? 'style' : 'script');
- case 26:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- }))();
+ if ( true && !isDependency) {
+ this.getDependencies(route).then(function (urls) {
+ return urls.forEach(function (url) {
+ _this5.prefetch(url, true);
+ });
+ });
+ }
}
}]); Diff for main-HASH.module.js@@ -341,7 +341,7 @@ if (!window.Promise) {
var data = JSON.parse(document.getElementById('__NEXT_DATA__').textContent);
window.__NEXT_DATA__ = data;
-var version = "9.1.7-canary.3";
+var version = "9.1.7-canary.2";
exports.version = version;
var {
props,
@@ -1081,32 +1081,28 @@ var _mitt = _interopRequireDefault(__webpack_require__("dZ6Y"));
/* global document, window */
-var prefetchOrPreload = undefined ? 'prefetch' : 'preload';
-
-function supportsPreload(el) {
+function hasPrefetch(link) {
try {
- return el.relList.supports(prefetchOrPreload);
+ link = document.createElement('link');
+ return link.relList.supports('prefetch');
} catch (_unused) {
return false;
}
}
-var hasPreload = supportsPreload(document.createElement('link'));
+var relPrefetch = hasPrefetch() ? // https://caniuse.com/#feat=link-rel-prefetch
+// IE 11, Edge 12+, nearly all evergreen
+'prefetch' : // https://caniuse.com/#feat=link-rel-preload
+// macOS and iOS (Safari does not support prefetch)
+'preload';
+var hasNoModule = 'noModule' in document.createElement('script');
-function preloadLink(url, resourceType) {
+function appendLink(href, rel, as) {
var link = document.createElement('link');
- link.rel = prefetchOrPreload;
link.crossOrigin = "anonymous";
- link.href = url;
- link.as = resourceType;
- document.head.appendChild(link);
-}
-
-function loadStyle(url) {
- var link = document.createElement('link');
- link.rel = 'stylesheet';
- link.crossOrigin = "anonymous";
- link.href = url;
+ link.href = href;
+ link.rel = rel;
+ if (as) link.as = as;
document.head.appendChild(link);
}
@@ -1206,7 +1202,7 @@ class PageLoader {
}
if (/\.css$/.test(d) && !document.querySelector("link[rel=stylesheet][href^=\"" + d + "\"]")) {
- loadStyle(d); // FIXME: handle failure
+ appendLink(d, 'stylesheet'); // FIXME: handle failure
}
});
this.loadRoute(route);
@@ -1232,7 +1228,7 @@ class PageLoader {
loadScript(url, route, isPage) {
var script = document.createElement('script');
- if ( true && 'noModule' in script) {
+ if ( true && hasNoModule) {
script.type = 'module'; // Only page bundle scripts need to have .module added to url,
// dependencies already have it added during build manifest creation
@@ -1280,65 +1276,42 @@ class PageLoader {
}
prefetch(route, isDependency) {
- var _this2 = this;
-
- return (0, _asyncToGenerator2.default)(function* () {
- route = _this2.normalizeRoute(route);
- var scriptRoute = (route === '/' ? '/index' : route) + ".js";
+ // https://github.com/GoogleChromeLabs/quicklink/blob/453a661fa1fa940e2d2e044452398e38c67a98fb/src/index.mjs#L115-L118
+ // License: Apache 2.0
+ var cn;
- if ( true && 'noModule' in document.createElement('script')) {
- scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
- }
-
- var url = _this2.assetPrefix + (isDependency ? route : "/_next/static/" + encodeURIComponent(_this2.buildId) + "/pages" + encodeURI(scriptRoute)); // n.b. If preload is not supported, we fall back to `loadPage` which has
- // its own deduping mechanism.
-
- if (_this2.prefetched[route] || document.querySelector("link[rel=\"" + prefetchOrPreload + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
- return;
- }
+ if (cn = navigator.connection) {
+ // Don't prefetch if using 2G or if Save-Data is enabled.
+ if (cn.saveData || /2g/.test(cn.effectiveType)) return;
+ }
- _this2.prefetched[route] = true; // Inspired by quicklink, license: https://github.com/GoogleChromeLabs/quicklink/blob/master/LICENSE
+ var url = this.assetPrefix;
- var cn;
+ if (isDependency) {
+ url += route;
+ } else {
+ route = this.normalizeRoute(route);
+ this.prefetched[route] = true;
+ var scriptRoute = (route === '/' ? '/index' : route) + ".js";
- if (cn = navigator.connection) {
- // Don't prefetch if the user is on 2G or if Save-Data is enabled.
- if ((cn.effectiveType || '').indexOf('2g') !== -1 || cn.saveData) {
- return;
- }
+ if ( true && hasNoModule) {
+ scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
}
- if ( true && !isDependency) {
- ;
- (yield _this2.getDependencies(route)).forEach(url => {
- _this2.prefetch(url, true);
- });
- } // Feature detection is used to see if preload is supported
- // If not fall back to loading script tags before the page is loaded
- // https://caniuse.com/#feat=link-rel-preload
+ url += "/_next/static/" + encodeURIComponent(this.buildId) + "/pages" + encodeURI(scriptRoute);
+ }
+ if (document.querySelector("link[rel=\"" + relPrefetch + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
+ return;
+ }
- if (hasPreload) {
- preloadLink(url, url.match(/\.css$/) ? 'style' : 'script');
- return;
- }
+ appendLink(url, relPrefetch, url.match(/\.css$/) ? 'style' : 'script');
- if (isDependency) {
- // loadPage will automatically handle dependencies, so no need to
- // preload them manually
- return;
- }
-
- if (document.readyState === 'complete') {
- return _this2.loadPage(route).catch(() => {});
- } else {
- return new _promise.default(resolve => {
- window.addEventListener('load', () => {
- _this2.loadPage(route).then(() => resolve(), () => resolve());
- });
- });
- }
- })();
+ if ( true && !isDependency) {
+ this.getDependencies(route).then(urls => urls.forEach(url => {
+ this.prefetch(url, true);
+ }));
+ }
}
} Diff for index.html@@ -12,7 +12,7 @@
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/runtime/webpack-7928590be3ef2e55b835.module.js"
as="script" crossorigin="anonymous" />
- <link rel="preload" href="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/chunks/framework.9c9aa574c484a7d0240e.module.js"
as="script" crossorigin="anonymous" />
@@ -44,9 +44,9 @@
async="" crossorigin="anonymous" nomodule=""></script>
<script src="/_next/static/runtime/webpack-7928590be3ef2e55b835.module.js"
async="" crossorigin="anonymous" type="module"></script>
- <script src="/_next/static/runtime/main-c7894c8b919067f5cc96.js"
+ <script src="/_next/static/runtime/main-61c9f5a18beee988f275.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <script src="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
async="" crossorigin="anonymous" type="module"></script>
<script src="/_next/static/chunks/framework.4c64484d8a631a55b435.js"
async="" crossorigin="anonymous" nomodule=""></script> Diff for link.html@@ -18,7 +18,7 @@
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
as="script" crossorigin="anonymous" />
- <link rel="preload" href="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
as="script" crossorigin="anonymous" />
</head>
@@ -61,9 +61,9 @@
async="" crossorigin="anonymous" nomodule=""></script>
<script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
async="" crossorigin="anonymous" type="module"></script>
- <script src="/_next/static/runtime/main-c7894c8b919067f5cc96.js"
+ <script src="/_next/static/runtime/main-61c9f5a18beee988f275.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <script src="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
async="" crossorigin="anonymous" type="module"></script>
<script src="/_next/static/BUILD_ID/_buildManifest.js" async=""
crossorigin="anonymous" nomodule=""></script> Diff for withRouter.html@@ -18,7 +18,7 @@
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
as="script" crossorigin="anonymous" />
- <link rel="preload" href="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
as="script" crossorigin="anonymous" />
</head>
@@ -59,9 +59,9 @@
async="" crossorigin="anonymous" nomodule=""></script>
<script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
async="" crossorigin="anonymous" type="module"></script>
- <script src="/_next/static/runtime/main-c7894c8b919067f5cc96.js"
+ <script src="/_next/static/runtime/main-61c9f5a18beee988f275.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <script src="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
async="" crossorigin="anonymous" type="module"></script>
<script src="/_next/static/BUILD_ID/_buildManifest.js" async=""
crossorigin="anonymous" nomodule=""></script> Serverless Mode (Decrease detected ✓)General Overall decrease ✓
Client Bundles (main, webpack, commons) Overall decrease ✓
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
Legacy Client Bundles (polyfills)
Client Pages
Client Pages Modern
Client Build Manifests
Serverless bundles Overall decrease ✓
Commit: 7f02403 |
Stats from current PRDefault Server Mode (Decrease detected ✓)General Overall decrease ✓
Client Bundles (main, webpack, commons) Overall decrease ✓
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
Legacy Client Bundles (polyfills)
Client Pages
Client Pages Modern
Client Build Manifests
Rendered Page Sizes
DiffsDiff for main-HASH.js@@ -437,7 +437,7 @@ if (!window.Promise) {
var data = JSON.parse(document.getElementById('__NEXT_DATA__').textContent);
window.__NEXT_DATA__ = data;
-var version = "9.1.7-canary.3";
+var version = "9.1.7-canary.2";
exports.version = version;
var props = data.props,
err = data.err,
@@ -1390,32 +1390,28 @@ var _mitt = _interopRequireDefault(__webpack_require__("dZ6Y"));
/* global document, window */
-var prefetchOrPreload = undefined ? 'prefetch' : 'preload';
-
-function supportsPreload(el) {
+function hasPrefetch(link) {
try {
- return el.relList.supports(prefetchOrPreload);
+ link = document.createElement('link');
+ return link.relList.supports('prefetch');
} catch (_unused) {
return false;
}
}
-var hasPreload = supportsPreload(document.createElement('link'));
+var relPrefetch = hasPrefetch() ? // https://caniuse.com/#feat=link-rel-prefetch
+// IE 11, Edge 12+, nearly all evergreen
+'prefetch' : // https://caniuse.com/#feat=link-rel-preload
+// macOS and iOS (Safari does not support prefetch)
+'preload';
+var hasNoModule = 'noModule' in document.createElement('script');
-function preloadLink(url, resourceType) {
+function appendLink(href, rel, as) {
var link = document.createElement('link');
- link.rel = prefetchOrPreload;
link.crossOrigin = "anonymous";
- link.href = url;
- link.as = resourceType;
- document.head.appendChild(link);
-}
-
-function loadStyle(url) {
- var link = document.createElement('link');
- link.rel = 'stylesheet';
- link.crossOrigin = "anonymous";
- link.href = url;
+ link.href = href;
+ link.rel = rel;
+ if (as) link.as = as;
document.head.appendChild(link);
}
@@ -1476,7 +1472,7 @@ function () {
}, {
key: "loadPageScript",
value: function loadPageScript(route) {
- var _this3 = this;
+ var _this2 = this;
route = this.normalizeRoute(route);
return new _promise["default"](function (resolve, reject) {
@@ -1485,9 +1481,9 @@ function () {
page = _ref.page,
mod = _ref.mod;
- _this3.pageRegisterEvents.off(route, fire);
+ _this2.pageRegisterEvents.off(route, fire);
- delete _this3.loadingRoutes[route];
+ delete _this2.loadingRoutes[route];
if (error) {
reject(error);
@@ -1500,7 +1496,7 @@ function () {
}; // If there's a cached version of the page, let's use it.
- var cachedPage = _this3.pageCache[route];
+ var cachedPage = _this2.pageCache[route];
if (cachedPage) {
var error = cachedPage.error,
@@ -1514,7 +1510,7 @@ function () {
} // Register a listener to get the page
- _this3.pageRegisterEvents.on(route, fire); // If the page is loading via SSR, we need to wait for it
+ _this2.pageRegisterEvents.on(route, fire); // If the page is loading via SSR, we need to wait for it
// rather downloading it again.
@@ -1522,22 +1518,22 @@ function () {
return;
}
- if (!_this3.loadingRoutes[route]) {
+ if (!_this2.loadingRoutes[route]) {
if (true) {
- _this3.getDependencies(route).then(function (deps) {
+ _this2.getDependencies(route).then(function (deps) {
deps.forEach(function (d) {
if (/\.js$/.test(d) && !document.querySelector("script[src^=\"" + d + "\"]")) {
- _this3.loadScript(d, route, false);
+ _this2.loadScript(d, route, false);
}
if (/\.css$/.test(d) && !document.querySelector("link[rel=stylesheet][href^=\"" + d + "\"]")) {
- loadStyle(d); // FIXME: handle failure
+ appendLink(d, 'stylesheet'); // FIXME: handle failure
}
});
- _this3.loadRoute(route);
+ _this2.loadRoute(route);
- _this3.loadingRoutes[route] = true;
+ _this2.loadingRoutes[route] = true;
});
} else {}
}
@@ -1573,11 +1569,11 @@ function () {
}, {
key: "loadScript",
value: function loadScript(url, route, isPage) {
- var _this4 = this;
+ var _this3 = this;
var script = document.createElement('script');
- if ( true && 'noModule' in script) {
+ if ( true && hasNoModule) {
script.type = 'module'; // Only page bundle scripts need to have .module added to url,
// dependencies already have it added during build manifest creation
@@ -1591,7 +1587,7 @@ function () {
var error = new Error("Error loading script " + url);
error.code = 'PAGE_LOAD_ERROR';
- _this4.pageRegisterEvents.emit(route, {
+ _this3.pageRegisterEvents.emit(route, {
error: error
});
};
@@ -1602,7 +1598,7 @@ function () {
}, {
key: "registerPage",
value: function registerPage(route, regFn) {
- var _this5 = this;
+ var _this4 = this;
var register = function register() {
try {
@@ -1611,15 +1607,15 @@ function () {
page: mod["default"] || mod,
mod: mod
};
- _this5.pageCache[route] = pageData;
+ _this4.pageCache[route] = pageData;
- _this5.pageRegisterEvents.emit(route, pageData);
+ _this4.pageRegisterEvents.emit(route, pageData);
} catch (error) {
- _this5.pageCache[route] = {
+ _this4.pageCache[route] = {
error: error
};
- _this5.pageRegisterEvents.emit(route, {
+ _this4.pageRegisterEvents.emit(route, {
error: error
});
}
@@ -1632,108 +1628,46 @@ function () {
}, {
key: "prefetch",
value: function prefetch(route, isDependency) {
- var _this2 = this;
-
- return (0, _asyncToGenerator2["default"])(
- /*#__PURE__*/
- _regeneratorRuntime.mark(function _callee2() {
- var scriptRoute, url, cn;
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- route = _this2.normalizeRoute(route);
- scriptRoute = (route === '/' ? '/index' : route) + ".js";
-
- if ( true && 'noModule' in document.createElement('script')) {
- scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
- }
-
- url = _this2.assetPrefix + (isDependency ? route : "/_next/static/" + encodeURIComponent(_this2.buildId) + "/pages" + encodeURI(scriptRoute)); // n.b. If preload is not supported, we fall back to `loadPage` which has
- // its own deduping mechanism.
-
- if (!(_this2.prefetched[route] || document.querySelector("link[rel=\"" + prefetchOrPreload + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]"))) {
- _context2.next = 6;
- break;
- }
-
- return _context2.abrupt("return");
-
- case 6:
- _this2.prefetched[route] = true; // Inspired by quicklink, license: https://github.com/GoogleChromeLabs/quicklink/blob/master/LICENSE
-
- if (!(cn = navigator.connection)) {
- _context2.next = 10;
- break;
- }
-
- if (!((cn.effectiveType || '').indexOf('2g') !== -1 || cn.saveData)) {
- _context2.next = 10;
- break;
- }
-
- return _context2.abrupt("return");
-
- case 10:
- if (!( true && !isDependency)) {
- _context2.next = 16;
- break;
- }
-
- ;
- _context2.next = 14;
- return _this2.getDependencies(route);
-
- case 14:
- _context2.t0 = function (url) {
- _this2.prefetch(url, true);
- };
+ var _this5 = this;
- _context2.sent.forEach(_context2.t0);
+ // https://github.com/GoogleChromeLabs/quicklink/blob/453a661fa1fa940e2d2e044452398e38c67a98fb/src/index.mjs#L115-L118
+ // License: Apache 2.0
+ var cn;
- case 16:
- if (!hasPreload) {
- _context2.next = 19;
- break;
- }
+ if (cn = navigator.connection) {
+ // Don't prefetch if using 2G or if Save-Data is enabled.
+ if (cn.saveData || /2g/.test(cn.effectiveType)) return;
+ }
- preloadLink(url, url.match(/\.css$/) ? 'style' : 'script');
- return _context2.abrupt("return");
+ var url = this.assetPrefix;
- case 19:
- if (!isDependency) {
- _context2.next = 21;
- break;
- }
+ if (isDependency) {
+ url += route;
+ } else {
+ route = this.normalizeRoute(route);
+ this.prefetched[route] = true;
+ var scriptRoute = (route === '/' ? '/index' : route) + ".js";
- return _context2.abrupt("return");
+ if ( true && hasNoModule) {
+ scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
+ }
- case 21:
- if (!(document.readyState === 'complete')) {
- _context2.next = 25;
- break;
- }
+ url += "/_next/static/" + encodeURIComponent(this.buildId) + "/pages" + encodeURI(scriptRoute);
+ }
- return _context2.abrupt("return", _this2.loadPage(route)["catch"](function () {}));
+ if (document.querySelector("link[rel=\"" + relPrefetch + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
+ return;
+ }
- case 25:
- return _context2.abrupt("return", new _promise["default"](function (resolve) {
- window.addEventListener('load', function () {
- _this2.loadPage(route).then(function () {
- return resolve();
- }, function () {
- return resolve();
- });
- });
- }));
+ appendLink(url, relPrefetch, url.match(/\.css$/) ? 'style' : 'script');
- case 26:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- }))();
+ if ( true && !isDependency) {
+ this.getDependencies(route).then(function (urls) {
+ return urls.forEach(function (url) {
+ _this5.prefetch(url, true);
+ });
+ });
+ }
}
}]); Diff for main-HASH.module.js@@ -341,7 +341,7 @@ if (!window.Promise) {
var data = JSON.parse(document.getElementById('__NEXT_DATA__').textContent);
window.__NEXT_DATA__ = data;
-var version = "9.1.7-canary.3";
+var version = "9.1.7-canary.2";
exports.version = version;
var {
props,
@@ -1081,32 +1081,28 @@ var _mitt = _interopRequireDefault(__webpack_require__("dZ6Y"));
/* global document, window */
-var prefetchOrPreload = undefined ? 'prefetch' : 'preload';
-
-function supportsPreload(el) {
+function hasPrefetch(link) {
try {
- return el.relList.supports(prefetchOrPreload);
+ link = document.createElement('link');
+ return link.relList.supports('prefetch');
} catch (_unused) {
return false;
}
}
-var hasPreload = supportsPreload(document.createElement('link'));
+var relPrefetch = hasPrefetch() ? // https://caniuse.com/#feat=link-rel-prefetch
+// IE 11, Edge 12+, nearly all evergreen
+'prefetch' : // https://caniuse.com/#feat=link-rel-preload
+// macOS and iOS (Safari does not support prefetch)
+'preload';
+var hasNoModule = 'noModule' in document.createElement('script');
-function preloadLink(url, resourceType) {
+function appendLink(href, rel, as) {
var link = document.createElement('link');
- link.rel = prefetchOrPreload;
link.crossOrigin = "anonymous";
- link.href = url;
- link.as = resourceType;
- document.head.appendChild(link);
-}
-
-function loadStyle(url) {
- var link = document.createElement('link');
- link.rel = 'stylesheet';
- link.crossOrigin = "anonymous";
- link.href = url;
+ link.href = href;
+ link.rel = rel;
+ if (as) link.as = as;
document.head.appendChild(link);
}
@@ -1206,7 +1202,7 @@ class PageLoader {
}
if (/\.css$/.test(d) && !document.querySelector("link[rel=stylesheet][href^=\"" + d + "\"]")) {
- loadStyle(d); // FIXME: handle failure
+ appendLink(d, 'stylesheet'); // FIXME: handle failure
}
});
this.loadRoute(route);
@@ -1232,7 +1228,7 @@ class PageLoader {
loadScript(url, route, isPage) {
var script = document.createElement('script');
- if ( true && 'noModule' in script) {
+ if ( true && hasNoModule) {
script.type = 'module'; // Only page bundle scripts need to have .module added to url,
// dependencies already have it added during build manifest creation
@@ -1280,65 +1276,42 @@ class PageLoader {
}
prefetch(route, isDependency) {
- var _this2 = this;
-
- return (0, _asyncToGenerator2.default)(function* () {
- route = _this2.normalizeRoute(route);
- var scriptRoute = (route === '/' ? '/index' : route) + ".js";
+ // https://github.com/GoogleChromeLabs/quicklink/blob/453a661fa1fa940e2d2e044452398e38c67a98fb/src/index.mjs#L115-L118
+ // License: Apache 2.0
+ var cn;
- if ( true && 'noModule' in document.createElement('script')) {
- scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
- }
-
- var url = _this2.assetPrefix + (isDependency ? route : "/_next/static/" + encodeURIComponent(_this2.buildId) + "/pages" + encodeURI(scriptRoute)); // n.b. If preload is not supported, we fall back to `loadPage` which has
- // its own deduping mechanism.
-
- if (_this2.prefetched[route] || document.querySelector("link[rel=\"" + prefetchOrPreload + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
- return;
- }
+ if (cn = navigator.connection) {
+ // Don't prefetch if using 2G or if Save-Data is enabled.
+ if (cn.saveData || /2g/.test(cn.effectiveType)) return;
+ }
- _this2.prefetched[route] = true; // Inspired by quicklink, license: https://github.com/GoogleChromeLabs/quicklink/blob/master/LICENSE
+ var url = this.assetPrefix;
- var cn;
+ if (isDependency) {
+ url += route;
+ } else {
+ route = this.normalizeRoute(route);
+ this.prefetched[route] = true;
+ var scriptRoute = (route === '/' ? '/index' : route) + ".js";
- if (cn = navigator.connection) {
- // Don't prefetch if the user is on 2G or if Save-Data is enabled.
- if ((cn.effectiveType || '').indexOf('2g') !== -1 || cn.saveData) {
- return;
- }
+ if ( true && hasNoModule) {
+ scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
}
- if ( true && !isDependency) {
- ;
- (yield _this2.getDependencies(route)).forEach(url => {
- _this2.prefetch(url, true);
- });
- } // Feature detection is used to see if preload is supported
- // If not fall back to loading script tags before the page is loaded
- // https://caniuse.com/#feat=link-rel-preload
+ url += "/_next/static/" + encodeURIComponent(this.buildId) + "/pages" + encodeURI(scriptRoute);
+ }
+ if (document.querySelector("link[rel=\"" + relPrefetch + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
+ return;
+ }
- if (hasPreload) {
- preloadLink(url, url.match(/\.css$/) ? 'style' : 'script');
- return;
- }
+ appendLink(url, relPrefetch, url.match(/\.css$/) ? 'style' : 'script');
- if (isDependency) {
- // loadPage will automatically handle dependencies, so no need to
- // preload them manually
- return;
- }
-
- if (document.readyState === 'complete') {
- return _this2.loadPage(route).catch(() => {});
- } else {
- return new _promise.default(resolve => {
- window.addEventListener('load', () => {
- _this2.loadPage(route).then(() => resolve(), () => resolve());
- });
- });
- }
- })();
+ if ( true && !isDependency) {
+ this.getDependencies(route).then(urls => urls.forEach(url => {
+ this.prefetch(url, true);
+ }));
+ }
}
} Diff for index.html@@ -12,7 +12,7 @@
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/runtime/webpack-7928590be3ef2e55b835.module.js"
as="script" crossorigin="anonymous" />
- <link rel="preload" href="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/chunks/framework.9c9aa574c484a7d0240e.module.js"
as="script" crossorigin="anonymous" />
@@ -44,9 +44,9 @@
async="" crossorigin="anonymous" nomodule=""></script>
<script src="/_next/static/runtime/webpack-7928590be3ef2e55b835.module.js"
async="" crossorigin="anonymous" type="module"></script>
- <script src="/_next/static/runtime/main-c7894c8b919067f5cc96.js"
+ <script src="/_next/static/runtime/main-61c9f5a18beee988f275.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <script src="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
async="" crossorigin="anonymous" type="module"></script>
<script src="/_next/static/chunks/framework.4c64484d8a631a55b435.js"
async="" crossorigin="anonymous" nomodule=""></script> Diff for link.html@@ -18,7 +18,7 @@
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
as="script" crossorigin="anonymous" />
- <link rel="preload" href="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
as="script" crossorigin="anonymous" />
</head>
@@ -61,9 +61,9 @@
async="" crossorigin="anonymous" nomodule=""></script>
<script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
async="" crossorigin="anonymous" type="module"></script>
- <script src="/_next/static/runtime/main-c7894c8b919067f5cc96.js"
+ <script src="/_next/static/runtime/main-61c9f5a18beee988f275.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <script src="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
async="" crossorigin="anonymous" type="module"></script>
<script src="/_next/static/BUILD_ID/_buildManifest.js" async=""
crossorigin="anonymous" nomodule=""></script> Diff for withRouter.html@@ -18,7 +18,7 @@
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
as="script" crossorigin="anonymous" />
- <link rel="preload" href="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
as="script" crossorigin="anonymous" />
</head>
@@ -59,9 +59,9 @@
async="" crossorigin="anonymous" nomodule=""></script>
<script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
async="" crossorigin="anonymous" type="module"></script>
- <script src="/_next/static/runtime/main-c7894c8b919067f5cc96.js"
+ <script src="/_next/static/runtime/main-61c9f5a18beee988f275.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <script src="/_next/static/runtime/main-68ef09cab458ca1f02cf.module.js"
async="" crossorigin="anonymous" type="module"></script>
<script src="/_next/static/BUILD_ID/_buildManifest.js" async=""
crossorigin="anonymous" nomodule=""></script> Serverless Mode (Decrease detected ✓)General Overall decrease ✓
Client Bundles (main, webpack, commons) Overall decrease ✓
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
Legacy Client Bundles (polyfills)
Client Pages
Client Pages Modern
Client Build Manifests
Serverless bundles Overall decrease ✓
Commit: c47e246 |
Stats from current PRDefault Server Mode (Decrease detected ✓)General Overall decrease ✓
Client Bundles (main, webpack, commons) Overall decrease ✓
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
Legacy Client Bundles (polyfills)
Client Pages
Client Pages Modern
Client Build Manifests
Rendered Page Sizes
DiffsDiff for main-HASH.js@@ -1390,32 +1390,28 @@ var _mitt = _interopRequireDefault(__webpack_require__("dZ6Y"));
/* global document, window */
-var prefetchOrPreload = undefined ? 'prefetch' : 'preload';
-
-function supportsPreload(el) {
+function hasPrefetch(link) {
try {
- return el.relList.supports(prefetchOrPreload);
+ link = document.createElement('link');
+ return link.relList.supports('prefetch');
} catch (_unused) {
return false;
}
}
-var hasPreload = supportsPreload(document.createElement('link'));
+var relPrefetch = hasPrefetch() ? // https://caniuse.com/#feat=link-rel-prefetch
+// IE 11, Edge 12+, nearly all evergreen
+'prefetch' : // https://caniuse.com/#feat=link-rel-preload
+// macOS and iOS (Safari does not support prefetch)
+'preload';
+var hasNoModule = 'noModule' in document.createElement('script');
-function preloadLink(url, resourceType) {
+function appendLink(href, rel, as) {
var link = document.createElement('link');
- link.rel = prefetchOrPreload;
link.crossOrigin = "anonymous";
- link.href = url;
- link.as = resourceType;
- document.head.appendChild(link);
-}
-
-function loadStyle(url) {
- var link = document.createElement('link');
- link.rel = 'stylesheet';
- link.crossOrigin = "anonymous";
- link.href = url;
+ link.href = href;
+ link.rel = rel;
+ if (as) link.as = as;
document.head.appendChild(link);
}
@@ -1476,7 +1472,7 @@ function () {
}, {
key: "loadPageScript",
value: function loadPageScript(route) {
- var _this3 = this;
+ var _this2 = this;
route = this.normalizeRoute(route);
return new _promise["default"](function (resolve, reject) {
@@ -1485,9 +1481,9 @@ function () {
page = _ref.page,
mod = _ref.mod;
- _this3.pageRegisterEvents.off(route, fire);
+ _this2.pageRegisterEvents.off(route, fire);
- delete _this3.loadingRoutes[route];
+ delete _this2.loadingRoutes[route];
if (error) {
reject(error);
@@ -1500,7 +1496,7 @@ function () {
}; // If there's a cached version of the page, let's use it.
- var cachedPage = _this3.pageCache[route];
+ var cachedPage = _this2.pageCache[route];
if (cachedPage) {
var error = cachedPage.error,
@@ -1514,7 +1510,7 @@ function () {
} // Register a listener to get the page
- _this3.pageRegisterEvents.on(route, fire); // If the page is loading via SSR, we need to wait for it
+ _this2.pageRegisterEvents.on(route, fire); // If the page is loading via SSR, we need to wait for it
// rather downloading it again.
@@ -1522,22 +1518,22 @@ function () {
return;
}
- if (!_this3.loadingRoutes[route]) {
+ if (!_this2.loadingRoutes[route]) {
if (true) {
- _this3.getDependencies(route).then(function (deps) {
+ _this2.getDependencies(route).then(function (deps) {
deps.forEach(function (d) {
if (/\.js$/.test(d) && !document.querySelector("script[src^=\"" + d + "\"]")) {
- _this3.loadScript(d, route, false);
+ _this2.loadScript(d, route, false);
}
if (/\.css$/.test(d) && !document.querySelector("link[rel=stylesheet][href^=\"" + d + "\"]")) {
- loadStyle(d); // FIXME: handle failure
+ appendLink(d, 'stylesheet'); // FIXME: handle failure
}
});
- _this3.loadRoute(route);
+ _this2.loadRoute(route);
- _this3.loadingRoutes[route] = true;
+ _this2.loadingRoutes[route] = true;
});
} else {}
}
@@ -1573,11 +1569,11 @@ function () {
}, {
key: "loadScript",
value: function loadScript(url, route, isPage) {
- var _this4 = this;
+ var _this3 = this;
var script = document.createElement('script');
- if ( true && 'noModule' in script) {
+ if ( true && hasNoModule) {
script.type = 'module'; // Only page bundle scripts need to have .module added to url,
// dependencies already have it added during build manifest creation
@@ -1591,7 +1587,7 @@ function () {
var error = new Error("Error loading script " + url);
error.code = 'PAGE_LOAD_ERROR';
- _this4.pageRegisterEvents.emit(route, {
+ _this3.pageRegisterEvents.emit(route, {
error: error
});
};
@@ -1602,7 +1598,7 @@ function () {
}, {
key: "registerPage",
value: function registerPage(route, regFn) {
- var _this5 = this;
+ var _this4 = this;
var register = function register() {
try {
@@ -1611,15 +1607,15 @@ function () {
page: mod["default"] || mod,
mod: mod
};
- _this5.pageCache[route] = pageData;
+ _this4.pageCache[route] = pageData;
- _this5.pageRegisterEvents.emit(route, pageData);
+ _this4.pageRegisterEvents.emit(route, pageData);
} catch (error) {
- _this5.pageCache[route] = {
+ _this4.pageCache[route] = {
error: error
};
- _this5.pageRegisterEvents.emit(route, {
+ _this4.pageRegisterEvents.emit(route, {
error: error
});
}
@@ -1632,108 +1628,46 @@ function () {
}, {
key: "prefetch",
value: function prefetch(route, isDependency) {
- var _this2 = this;
-
- return (0, _asyncToGenerator2["default"])(
- /*#__PURE__*/
- _regeneratorRuntime.mark(function _callee2() {
- var scriptRoute, url, cn;
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
- while (1) {
- switch (_context2.prev = _context2.next) {
- case 0:
- route = _this2.normalizeRoute(route);
- scriptRoute = (route === '/' ? '/index' : route) + ".js";
-
- if ( true && 'noModule' in document.createElement('script')) {
- scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
- }
-
- url = _this2.assetPrefix + (isDependency ? route : "/_next/static/" + encodeURIComponent(_this2.buildId) + "/pages" + encodeURI(scriptRoute)); // n.b. If preload is not supported, we fall back to `loadPage` which has
- // its own deduping mechanism.
-
- if (!(_this2.prefetched[route] || document.querySelector("link[rel=\"" + prefetchOrPreload + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]"))) {
- _context2.next = 6;
- break;
- }
-
- return _context2.abrupt("return");
-
- case 6:
- _this2.prefetched[route] = true; // Inspired by quicklink, license: https://github.com/GoogleChromeLabs/quicklink/blob/master/LICENSE
-
- if (!(cn = navigator.connection)) {
- _context2.next = 10;
- break;
- }
-
- if (!((cn.effectiveType || '').indexOf('2g') !== -1 || cn.saveData)) {
- _context2.next = 10;
- break;
- }
-
- return _context2.abrupt("return");
-
- case 10:
- if (!( true && !isDependency)) {
- _context2.next = 16;
- break;
- }
-
- ;
- _context2.next = 14;
- return _this2.getDependencies(route);
-
- case 14:
- _context2.t0 = function (url) {
- _this2.prefetch(url, true);
- };
+ var _this5 = this;
- _context2.sent.forEach(_context2.t0);
+ // https://github.com/GoogleChromeLabs/quicklink/blob/453a661fa1fa940e2d2e044452398e38c67a98fb/src/index.mjs#L115-L118
+ // License: Apache 2.0
+ var cn;
- case 16:
- if (!hasPreload) {
- _context2.next = 19;
- break;
- }
+ if (cn = navigator.connection) {
+ // Don't prefetch if using 2G or if Save-Data is enabled.
+ if (cn.saveData || /2g/.test(cn.effectiveType)) return;
+ }
- preloadLink(url, url.match(/\.css$/) ? 'style' : 'script');
- return _context2.abrupt("return");
+ var url = this.assetPrefix;
- case 19:
- if (!isDependency) {
- _context2.next = 21;
- break;
- }
+ if (isDependency) {
+ url += route;
+ } else {
+ route = this.normalizeRoute(route);
+ this.prefetched[route] = true;
+ var scriptRoute = (route === '/' ? '/index' : route) + ".js";
- return _context2.abrupt("return");
+ if ( true && hasNoModule) {
+ scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
+ }
- case 21:
- if (!(document.readyState === 'complete')) {
- _context2.next = 25;
- break;
- }
+ url += "/_next/static/" + encodeURIComponent(this.buildId) + "/pages" + encodeURI(scriptRoute);
+ }
- return _context2.abrupt("return", _this2.loadPage(route)["catch"](function () {}));
+ if (document.querySelector("link[rel=\"" + relPrefetch + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
+ return;
+ }
- case 25:
- return _context2.abrupt("return", new _promise["default"](function (resolve) {
- window.addEventListener('load', function () {
- _this2.loadPage(route).then(function () {
- return resolve();
- }, function () {
- return resolve();
- });
- });
- }));
+ appendLink(url, relPrefetch, url.match(/\.css$/) ? 'style' : 'script');
- case 26:
- case "end":
- return _context2.stop();
- }
- }
- }, _callee2);
- }))();
+ if ( true && !isDependency) {
+ this.getDependencies(route).then(function (urls) {
+ return urls.forEach(function (url) {
+ _this5.prefetch(url, true);
+ });
+ });
+ }
}
}]); Diff for main-HASH.module.js@@ -1081,32 +1081,28 @@ var _mitt = _interopRequireDefault(__webpack_require__("dZ6Y"));
/* global document, window */
-var prefetchOrPreload = undefined ? 'prefetch' : 'preload';
-
-function supportsPreload(el) {
+function hasPrefetch(link) {
try {
- return el.relList.supports(prefetchOrPreload);
+ link = document.createElement('link');
+ return link.relList.supports('prefetch');
} catch (_unused) {
return false;
}
}
-var hasPreload = supportsPreload(document.createElement('link'));
+var relPrefetch = hasPrefetch() ? // https://caniuse.com/#feat=link-rel-prefetch
+// IE 11, Edge 12+, nearly all evergreen
+'prefetch' : // https://caniuse.com/#feat=link-rel-preload
+// macOS and iOS (Safari does not support prefetch)
+'preload';
+var hasNoModule = 'noModule' in document.createElement('script');
-function preloadLink(url, resourceType) {
+function appendLink(href, rel, as) {
var link = document.createElement('link');
- link.rel = prefetchOrPreload;
link.crossOrigin = "anonymous";
- link.href = url;
- link.as = resourceType;
- document.head.appendChild(link);
-}
-
-function loadStyle(url) {
- var link = document.createElement('link');
- link.rel = 'stylesheet';
- link.crossOrigin = "anonymous";
- link.href = url;
+ link.href = href;
+ link.rel = rel;
+ if (as) link.as = as;
document.head.appendChild(link);
}
@@ -1206,7 +1202,7 @@ class PageLoader {
}
if (/\.css$/.test(d) && !document.querySelector("link[rel=stylesheet][href^=\"" + d + "\"]")) {
- loadStyle(d); // FIXME: handle failure
+ appendLink(d, 'stylesheet'); // FIXME: handle failure
}
});
this.loadRoute(route);
@@ -1232,7 +1228,7 @@ class PageLoader {
loadScript(url, route, isPage) {
var script = document.createElement('script');
- if ( true && 'noModule' in script) {
+ if ( true && hasNoModule) {
script.type = 'module'; // Only page bundle scripts need to have .module added to url,
// dependencies already have it added during build manifest creation
@@ -1280,65 +1276,42 @@ class PageLoader {
}
prefetch(route, isDependency) {
- var _this2 = this;
-
- return (0, _asyncToGenerator2.default)(function* () {
- route = _this2.normalizeRoute(route);
- var scriptRoute = (route === '/' ? '/index' : route) + ".js";
+ // https://github.com/GoogleChromeLabs/quicklink/blob/453a661fa1fa940e2d2e044452398e38c67a98fb/src/index.mjs#L115-L118
+ // License: Apache 2.0
+ var cn;
- if ( true && 'noModule' in document.createElement('script')) {
- scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
- }
-
- var url = _this2.assetPrefix + (isDependency ? route : "/_next/static/" + encodeURIComponent(_this2.buildId) + "/pages" + encodeURI(scriptRoute)); // n.b. If preload is not supported, we fall back to `loadPage` which has
- // its own deduping mechanism.
-
- if (_this2.prefetched[route] || document.querySelector("link[rel=\"" + prefetchOrPreload + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
- return;
- }
+ if (cn = navigator.connection) {
+ // Don't prefetch if using 2G or if Save-Data is enabled.
+ if (cn.saveData || /2g/.test(cn.effectiveType)) return;
+ }
- _this2.prefetched[route] = true; // Inspired by quicklink, license: https://github.com/GoogleChromeLabs/quicklink/blob/master/LICENSE
+ var url = this.assetPrefix;
- var cn;
+ if (isDependency) {
+ url += route;
+ } else {
+ route = this.normalizeRoute(route);
+ this.prefetched[route] = true;
+ var scriptRoute = (route === '/' ? '/index' : route) + ".js";
- if (cn = navigator.connection) {
- // Don't prefetch if the user is on 2G or if Save-Data is enabled.
- if ((cn.effectiveType || '').indexOf('2g') !== -1 || cn.saveData) {
- return;
- }
+ if ( true && hasNoModule) {
+ scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
}
- if ( true && !isDependency) {
- ;
- (yield _this2.getDependencies(route)).forEach(url => {
- _this2.prefetch(url, true);
- });
- } // Feature detection is used to see if preload is supported
- // If not fall back to loading script tags before the page is loaded
- // https://caniuse.com/#feat=link-rel-preload
+ url += "/_next/static/" + encodeURIComponent(this.buildId) + "/pages" + encodeURI(scriptRoute);
+ }
+ if (document.querySelector("link[rel=\"" + relPrefetch + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
+ return;
+ }
- if (hasPreload) {
- preloadLink(url, url.match(/\.css$/) ? 'style' : 'script');
- return;
- }
+ appendLink(url, relPrefetch, url.match(/\.css$/) ? 'style' : 'script');
- if (isDependency) {
- // loadPage will automatically handle dependencies, so no need to
- // preload them manually
- return;
- }
-
- if (document.readyState === 'complete') {
- return _this2.loadPage(route).catch(() => {});
- } else {
- return new _promise.default(resolve => {
- window.addEventListener('load', () => {
- _this2.loadPage(route).then(() => resolve(), () => resolve());
- });
- });
- }
- })();
+ if ( true && !isDependency) {
+ this.getDependencies(route).then(urls => urls.forEach(url => {
+ this.prefetch(url, true);
+ }));
+ }
}
} Diff for index.html@@ -12,7 +12,7 @@
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/runtime/webpack-7928590be3ef2e55b835.module.js"
as="script" crossorigin="anonymous" />
- <link rel="preload" href="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-c0e154c9c5e27167cccb.module.js"
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/chunks/framework.9c9aa574c484a7d0240e.module.js"
as="script" crossorigin="anonymous" />
@@ -44,9 +44,9 @@
async="" crossorigin="anonymous" nomodule=""></script>
<script src="/_next/static/runtime/webpack-7928590be3ef2e55b835.module.js"
async="" crossorigin="anonymous" type="module"></script>
- <script src="/_next/static/runtime/main-c7894c8b919067f5cc96.js"
+ <script src="/_next/static/runtime/main-092f6549c73c0b7a8ee7.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <script src="/_next/static/runtime/main-c0e154c9c5e27167cccb.module.js"
async="" crossorigin="anonymous" type="module"></script>
<script src="/_next/static/chunks/framework.4c64484d8a631a55b435.js"
async="" crossorigin="anonymous" nomodule=""></script> Diff for link.html@@ -18,7 +18,7 @@
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
as="script" crossorigin="anonymous" />
- <link rel="preload" href="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-c0e154c9c5e27167cccb.module.js"
as="script" crossorigin="anonymous" />
</head>
@@ -61,9 +61,9 @@
async="" crossorigin="anonymous" nomodule=""></script>
<script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
async="" crossorigin="anonymous" type="module"></script>
- <script src="/_next/static/runtime/main-c7894c8b919067f5cc96.js"
+ <script src="/_next/static/runtime/main-092f6549c73c0b7a8ee7.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <script src="/_next/static/runtime/main-c0e154c9c5e27167cccb.module.js"
async="" crossorigin="anonymous" type="module"></script>
<script src="/_next/static/BUILD_ID/_buildManifest.js" async=""
crossorigin="anonymous" nomodule=""></script> Diff for withRouter.html@@ -18,7 +18,7 @@
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
as="script" crossorigin="anonymous" />
- <link rel="preload" href="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-c0e154c9c5e27167cccb.module.js"
as="script" crossorigin="anonymous" />
</head>
@@ -59,9 +59,9 @@
async="" crossorigin="anonymous" nomodule=""></script>
<script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
async="" crossorigin="anonymous" type="module"></script>
- <script src="/_next/static/runtime/main-c7894c8b919067f5cc96.js"
+ <script src="/_next/static/runtime/main-092f6549c73c0b7a8ee7.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <script src="/_next/static/runtime/main-c0e154c9c5e27167cccb.module.js"
async="" crossorigin="anonymous" type="module"></script>
<script src="/_next/static/BUILD_ID/_buildManifest.js" async=""
crossorigin="anonymous" nomodule=""></script> Serverless Mode (Decrease detected ✓)General Overall decrease ✓
Client Bundles (main, webpack, commons) Overall decrease ✓
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
Legacy Client Bundles (polyfills)
Client Pages
Client Pages Modern
Client Build Manifests
Serverless bundles
Commit: 5c2753c |
Stats from current PRDefault Server Mode (Decrease detected ✓)General Overall decrease ✓
Client Bundles (main, webpack, commons) Overall decrease ✓
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
Legacy Client Bundles (polyfills)
Client Pages
Client Pages Modern
Client Build Manifests
Rendered Page Sizes
DiffsDiff for main-HASH.js@@ -1387,36 +1387,32 @@ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__("+oT+"));
var _promise = _interopRequireDefault(__webpack_require__("eVuF"));
var _mitt = _interopRequireDefault(__webpack_require__("dZ6Y"));
-/* global document, window */
-
-var prefetchOrPreload = undefined ? 'prefetch' : 'preload';
-
-function supportsPreload(el) {
+function hasPrefetch(link) {
try {
- return el.relList.supports(prefetchOrPreload);
- } catch (_unused) {
- return false;
- }
-}
-
-var hasPreload = supportsPreload(document.createElement('link'));
-
-function preloadLink(url, resourceType) {
- var link = document.createElement('link');
- link.rel = prefetchOrPreload;
- link.crossOrigin = "anonymous";
- link.href = url;
- link.as = resourceType;
- document.head.appendChild(link);
+ link = document.createElement('link');
+ return link.relList.supports('prefetch');
+ } catch (_unused) {}
}
-function loadStyle(url) {
- var link = document.createElement('link');
- link.rel = 'stylesheet';
- link.crossOrigin = "anonymous";
- link.href = url;
- document.head.appendChild(link);
+var relPrefetch = hasPrefetch() ? // https://caniuse.com/#feat=link-rel-prefetch
+// IE 11, Edge 12+, nearly all evergreen
+'prefetch' : // https://caniuse.com/#feat=link-rel-preload
+// macOS and iOS (Safari does not support prefetch)
+'preload';
+var hasNoModule = 'noModule' in document.createElement('script');
+
+function appendLink(href, rel, as) {
+ return new _promise["default"](function (res, rej, link) {
+ link = document.createElement('link');
+ link.crossOrigin = "anonymous";
+ link.href = href;
+ link.rel = rel;
+ if (as) link.as = as;
+ link.onload = res;
+ link.onerror = rej;
+ document.head.appendChild(link);
+ });
}
var PageLoader =
@@ -1531,7 +1527,9 @@ function () {
}
if (/\.css$/.test(d) && !document.querySelector("link[rel=stylesheet][href^=\"" + d + "\"]")) {
- loadStyle(d); // FIXME: handle failure
+ appendLink(d, 'stylesheet')["catch"](function () {// FIXME: handle failure
+ // Right now, this is needed to prevent an unhandled rejection.
+ });
}
});
@@ -1577,7 +1575,7 @@ function () {
var script = document.createElement('script');
- if ( true && 'noModule' in script) {
+ if ( true && hasNoModule) {
script.type = 'module'; // Only page bundle scripts need to have .module added to url,
// dependencies already have it added during build manifest creation
@@ -1637,97 +1635,57 @@ function () {
return (0, _asyncToGenerator2["default"])(
/*#__PURE__*/
_regeneratorRuntime.mark(function _callee2() {
- var scriptRoute, url, cn;
+ var cn, url, scriptRoute;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
- route = _this2.normalizeRoute(route);
- scriptRoute = (route === '/' ? '/index' : route) + ".js";
-
- if ( true && 'noModule' in document.createElement('script')) {
- scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
- }
-
- url = _this2.assetPrefix + (isDependency ? route : "/_next/static/" + encodeURIComponent(_this2.buildId) + "/pages" + encodeURI(scriptRoute)); // n.b. If preload is not supported, we fall back to `loadPage` which has
- // its own deduping mechanism.
-
- if (!(_this2.prefetched[route] || document.querySelector("link[rel=\"" + prefetchOrPreload + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]"))) {
- _context2.next = 6;
- break;
- }
-
- return _context2.abrupt("return");
-
- case 6:
- _this2.prefetched[route] = true; // Inspired by quicklink, license: https://github.com/GoogleChromeLabs/quicklink/blob/master/LICENSE
-
if (!(cn = navigator.connection)) {
- _context2.next = 10;
+ _context2.next = 3;
break;
}
- if (!((cn.effectiveType || '').indexOf('2g') !== -1 || cn.saveData)) {
- _context2.next = 10;
+ if (!(cn.saveData || /2g/.test(cn.effectiveType))) {
+ _context2.next = 3;
break;
}
return _context2.abrupt("return");
- case 10:
- if (!( true && !isDependency)) {
- _context2.next = 16;
- break;
- }
-
- ;
- _context2.next = 14;
- return _this2.getDependencies(route);
+ case 3:
+ url = _this2.assetPrefix;
- case 14:
- _context2.t0 = function (url) {
- _this2.prefetch(url, true);
- };
+ if (isDependency) {
+ url += route;
+ } else {
+ route = _this2.normalizeRoute(route);
+ _this2.prefetched[route] = true;
+ scriptRoute = (route === '/' ? '/index' : route) + ".js";
- _context2.sent.forEach(_context2.t0);
+ if ( true && hasNoModule) {
+ scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
+ }
- case 16:
- if (!hasPreload) {
- _context2.next = 19;
- break;
+ url += "/_next/static/" + encodeURIComponent(_this2.buildId) + "/pages" + encodeURI(scriptRoute);
}
- preloadLink(url, url.match(/\.css$/) ? 'style' : 'script');
- return _context2.abrupt("return");
-
- case 19:
- if (!isDependency) {
- _context2.next = 21;
+ if (!document.querySelector("link[rel=\"" + relPrefetch + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
+ _context2.next = 7;
break;
}
return _context2.abrupt("return");
- case 21:
- if (!(document.readyState === 'complete')) {
- _context2.next = 25;
- break;
- }
-
- return _context2.abrupt("return", _this2.loadPage(route)["catch"](function () {}));
-
- case 25:
- return _context2.abrupt("return", new _promise["default"](function (resolve) {
- window.addEventListener('load', function () {
- _this2.loadPage(route).then(function () {
- return resolve();
- }, function () {
- return resolve();
- });
- });
- }));
+ case 7:
+ return _context2.abrupt("return", _promise["default"].all([appendLink(url, relPrefetch, url.match(/\.css$/) ? 'style' : 'script'), true && !isDependency && _this2.getDependencies(route).then(function (urls) {
+ return _promise["default"].all(urls.map(function (url) {
+ return _this2.prefetch(url, true);
+ }));
+ })]).then( // do not return any data
+ function () {}, // swallow prefetch errors
+ function () {}));
- case 26:
+ case 8:
case "end":
return _context2.stop();
} Diff for main-HASH.module.js@@ -1078,36 +1078,32 @@ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__("+oT+"));
var _promise = _interopRequireDefault(__webpack_require__("eVuF"));
var _mitt = _interopRequireDefault(__webpack_require__("dZ6Y"));
-/* global document, window */
-
-var prefetchOrPreload = undefined ? 'prefetch' : 'preload';
-
-function supportsPreload(el) {
+function hasPrefetch(link) {
try {
- return el.relList.supports(prefetchOrPreload);
- } catch (_unused) {
- return false;
- }
+ link = document.createElement('link');
+ return link.relList.supports('prefetch');
+ } catch (_unused) {}
}
-var hasPreload = supportsPreload(document.createElement('link'));
-
-function preloadLink(url, resourceType) {
- var link = document.createElement('link');
- link.rel = prefetchOrPreload;
- link.crossOrigin = "anonymous";
- link.href = url;
- link.as = resourceType;
- document.head.appendChild(link);
-}
-
-function loadStyle(url) {
- var link = document.createElement('link');
- link.rel = 'stylesheet';
- link.crossOrigin = "anonymous";
- link.href = url;
- document.head.appendChild(link);
+var relPrefetch = hasPrefetch() ? // https://caniuse.com/#feat=link-rel-prefetch
+// IE 11, Edge 12+, nearly all evergreen
+'prefetch' : // https://caniuse.com/#feat=link-rel-preload
+// macOS and iOS (Safari does not support prefetch)
+'preload';
+var hasNoModule = 'noModule' in document.createElement('script');
+
+function appendLink(href, rel, as) {
+ return new _promise.default((res, rej, link) => {
+ link = document.createElement('link');
+ link.crossOrigin = "anonymous";
+ link.href = href;
+ link.rel = rel;
+ if (as) link.as = as;
+ link.onload = res;
+ link.onerror = rej;
+ document.head.appendChild(link);
+ });
}
class PageLoader {
@@ -1206,7 +1202,9 @@ class PageLoader {
}
if (/\.css$/.test(d) && !document.querySelector("link[rel=stylesheet][href^=\"" + d + "\"]")) {
- loadStyle(d); // FIXME: handle failure
+ appendLink(d, 'stylesheet').catch(() => {// FIXME: handle failure
+ // Right now, this is needed to prevent an unhandled rejection.
+ });
}
});
this.loadRoute(route);
@@ -1232,7 +1230,7 @@ class PageLoader {
loadScript(url, route, isPage) {
var script = document.createElement('script');
- if ( true && 'noModule' in script) {
+ if ( true && hasNoModule) {
script.type = 'module'; // Only page bundle scripts need to have .module added to url,
// dependencies already have it added during build manifest creation
@@ -1283,61 +1281,38 @@ class PageLoader {
var _this2 = this;
return (0, _asyncToGenerator2.default)(function* () {
- route = _this2.normalizeRoute(route);
- var scriptRoute = (route === '/' ? '/index' : route) + ".js";
-
- if ( true && 'noModule' in document.createElement('script')) {
- scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
- }
-
- var url = _this2.assetPrefix + (isDependency ? route : "/_next/static/" + encodeURIComponent(_this2.buildId) + "/pages" + encodeURI(scriptRoute)); // n.b. If preload is not supported, we fall back to `loadPage` which has
- // its own deduping mechanism.
-
- if (_this2.prefetched[route] || document.querySelector("link[rel=\"" + prefetchOrPreload + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
- return;
- }
-
- _this2.prefetched[route] = true; // Inspired by quicklink, license: https://github.com/GoogleChromeLabs/quicklink/blob/master/LICENSE
-
+ // https://github.com/GoogleChromeLabs/quicklink/blob/453a661fa1fa940e2d2e044452398e38c67a98fb/src/index.mjs#L115-L118
+ // License: Apache 2.0
var cn;
if (cn = navigator.connection) {
- // Don't prefetch if the user is on 2G or if Save-Data is enabled.
- if ((cn.effectiveType || '').indexOf('2g') !== -1 || cn.saveData) {
- return;
- }
+ // Don't prefetch if using 2G or if Save-Data is enabled.
+ if (cn.saveData || /2g/.test(cn.effectiveType)) return;
}
- if ( true && !isDependency) {
- ;
- (yield _this2.getDependencies(route)).forEach(url => {
- _this2.prefetch(url, true);
- });
- } // Feature detection is used to see if preload is supported
- // If not fall back to loading script tags before the page is loaded
- // https://caniuse.com/#feat=link-rel-preload
+ var url = _this2.assetPrefix;
+ if (isDependency) {
+ url += route;
+ } else {
+ route = _this2.normalizeRoute(route);
+ _this2.prefetched[route] = true;
+ var scriptRoute = (route === '/' ? '/index' : route) + ".js";
- if (hasPreload) {
- preloadLink(url, url.match(/\.css$/) ? 'style' : 'script');
- return;
+ if ( true && hasNoModule) {
+ scriptRoute = scriptRoute.replace(/\.js$/, '.module.js');
+ }
+
+ url += "/_next/static/" + encodeURIComponent(_this2.buildId) + "/pages" + encodeURI(scriptRoute);
}
- if (isDependency) {
- // loadPage will automatically handle dependencies, so no need to
- // preload them manually
+ if (document.querySelector("link[rel=\"" + relPrefetch + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
return;
}
- if (document.readyState === 'complete') {
- return _this2.loadPage(route).catch(() => {});
- } else {
- return new _promise.default(resolve => {
- window.addEventListener('load', () => {
- _this2.loadPage(route).then(() => resolve(), () => resolve());
- });
- });
- }
+ return _promise.default.all([appendLink(url, relPrefetch, url.match(/\.css$/) ? 'style' : 'script'), true && !isDependency && _this2.getDependencies(route).then(urls => _promise.default.all(urls.map(url => _this2.prefetch(url, true))))]).then( // do not return any data
+ () => {}, // swallow prefetch errors
+ () => {});
})();
} Diff for index.html@@ -12,7 +12,7 @@
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/runtime/webpack-7928590be3ef2e55b835.module.js"
as="script" crossorigin="anonymous" />
- <link rel="preload" href="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-e8a4701898cc078b37e0.module.js"
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/chunks/framework.9c9aa574c484a7d0240e.module.js"
as="script" crossorigin="anonymous" />
@@ -44,9 +44,9 @@
async="" crossorigin="anonymous" nomodule=""></script>
<script src="/_next/static/runtime/webpack-7928590be3ef2e55b835.module.js"
async="" crossorigin="anonymous" type="module"></script>
- <script src="/_next/static/runtime/main-c7894c8b919067f5cc96.js"
+ <script src="/_next/static/runtime/main-28970b5a87d524ca5f50.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <script src="/_next/static/runtime/main-e8a4701898cc078b37e0.module.js"
async="" crossorigin="anonymous" type="module"></script>
<script src="/_next/static/chunks/framework.4c64484d8a631a55b435.js"
async="" crossorigin="anonymous" nomodule=""></script> Diff for link.html@@ -18,7 +18,7 @@
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
as="script" crossorigin="anonymous" />
- <link rel="preload" href="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-e8a4701898cc078b37e0.module.js"
as="script" crossorigin="anonymous" />
</head>
@@ -61,9 +61,9 @@
async="" crossorigin="anonymous" nomodule=""></script>
<script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
async="" crossorigin="anonymous" type="module"></script>
- <script src="/_next/static/runtime/main-c7894c8b919067f5cc96.js"
+ <script src="/_next/static/runtime/main-28970b5a87d524ca5f50.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <script src="/_next/static/runtime/main-e8a4701898cc078b37e0.module.js"
async="" crossorigin="anonymous" type="module"></script>
<script src="/_next/static/BUILD_ID/_buildManifest.js" async=""
crossorigin="anonymous" nomodule=""></script> Diff for withRouter.html@@ -18,7 +18,7 @@
as="script" crossorigin="anonymous" />
<link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
as="script" crossorigin="anonymous" />
- <link rel="preload" href="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-e8a4701898cc078b37e0.module.js"
as="script" crossorigin="anonymous" />
</head>
@@ -59,9 +59,9 @@
async="" crossorigin="anonymous" nomodule=""></script>
<script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.bdb1895cb5ac008f5797.module.js"
async="" crossorigin="anonymous" type="module"></script>
- <script src="/_next/static/runtime/main-c7894c8b919067f5cc96.js"
+ <script src="/_next/static/runtime/main-28970b5a87d524ca5f50.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-dabb7de42544cbe5a6be.module.js"
+ <script src="/_next/static/runtime/main-e8a4701898cc078b37e0.module.js"
async="" crossorigin="anonymous" type="module"></script>
<script src="/_next/static/BUILD_ID/_buildManifest.js" async=""
crossorigin="anonymous" nomodule=""></script> Serverless Mode (Decrease detected ✓)General Overall decrease ✓
Client Bundles (main, webpack, commons) Overall decrease ✓
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
Legacy Client Bundles (polyfills)
Client Pages
Client Pages Modern
Client Build Manifests
Serverless bundles
Commit: 69ff434 |
timneutkens
approved these changes
Dec 24, 2019
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request optimizes our page loader's prefetching by changing the following:
prefetch
instead ofpreload
when available (so resource loads as low-priority). This lessens CPU load during hydration.preload
is still required for macOS (Safari) and iOS (iOS Safari).quicklink
<script>
preloading loading was removed as it was for backwards compat, which is now covered by wider-supportedprefetch
Contrary to an assumption we were operating on (IIRC),
preload
does not preparse the script. In fact,prefetch
should actually have better caching characteristics (forces storage in disk cache instead of in-memory, meaning less data transferred on n+1 visit).Only
<link rel="modulepreload">
(Chrome + ESModules only) parses a script prior to execution.