-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Add experiment for prefetching #9747
Merged
Merged
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.6-canary.9";
+var version = "9.1.6-canary.7";
exports.version = version;
var props = data.props,
err = data.err,
@@ -1390,9 +1390,11 @@ var _mitt = _interopRequireDefault(__webpack_require__("dZ6Y"));
/* global document, window */
+var prefetchOrPreload = undefined ? 'prefetch' : 'preload';
+
function supportsPreload(el) {
try {
- return el.relList.supports('preload');
+ return el.relList.supports(prefetchOrPreload);
} catch (_unused) {
return false;
}
@@ -1402,7 +1404,7 @@ var hasPreload = supportsPreload(document.createElement('link'));
function preloadLink(url, resourceType) {
var link = document.createElement('link');
- link.rel = 'preload';
+ link.rel = prefetchOrPreload;
link.crossOrigin = "anonymous";
link.href = url;
link.as = resourceType;
@@ -1649,7 +1651,7 @@ function () {
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 (!document.querySelector("link[rel=\"preload\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
+ if (!document.querySelector("link[rel=\"" + prefetchOrPreload + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
_context2.next = 6;
break;
} 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.6-canary.9";
+var version = "9.1.6-canary.7";
exports.version = version;
var {
props,
@@ -1081,9 +1081,11 @@ var _mitt = _interopRequireDefault(__webpack_require__("dZ6Y"));
/* global document, window */
+var prefetchOrPreload = undefined ? 'prefetch' : 'preload';
+
function supportsPreload(el) {
try {
- return el.relList.supports('preload');
+ return el.relList.supports(prefetchOrPreload);
} catch (_unused) {
return false;
}
@@ -1093,7 +1095,7 @@ var hasPreload = supportsPreload(document.createElement('link'));
function preloadLink(url, resourceType) {
var link = document.createElement('link');
- link.rel = 'preload';
+ link.rel = prefetchOrPreload;
link.crossOrigin = "anonymous";
link.href = url;
link.as = resourceType;
@@ -1290,7 +1292,7 @@ class PageLoader {
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 (document.querySelector("link[rel=\"preload\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
+ if (document.querySelector("link[rel=\"" + prefetchOrPreload + "\"][href^=\"" + url + "\"], script[data-next-page=\"" + route + "\"]")) {
return;
} // Inspired by quicklink, license: https://github.com/GoogleChromeLabs/quicklink/blob/master/LICENSE 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-bf090db607d67d7a250f.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-31ba2a71e4a52253b2d5.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-f0a7aeba24f91a93e8e7.js"
+ <script src="/_next/static/runtime/main-e20154f19e18f7fa4a76.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-bf090db607d67d7a250f.module.js"
+ <script src="/_next/static/runtime/main-31ba2a71e4a52253b2d5.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.6544e81bc61166e45e0f.module.js"
as="script" crossorigin="anonymous" />
- <link rel="preload" href="/_next/static/runtime/main-bf090db607d67d7a250f.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-31ba2a71e4a52253b2d5.module.js"
as="script" crossorigin="anonymous" />
</head>
@@ -61,9 +61,9 @@
async="" crossorigin="anonymous" nomodule=""></script>
<script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.6544e81bc61166e45e0f.module.js"
async="" crossorigin="anonymous" type="module"></script>
- <script src="/_next/static/runtime/main-f0a7aeba24f91a93e8e7.js"
+ <script src="/_next/static/runtime/main-e20154f19e18f7fa4a76.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-bf090db607d67d7a250f.module.js"
+ <script src="/_next/static/runtime/main-31ba2a71e4a52253b2d5.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.6544e81bc61166e45e0f.module.js"
as="script" crossorigin="anonymous" />
- <link rel="preload" href="/_next/static/runtime/main-bf090db607d67d7a250f.module.js"
+ <link rel="preload" href="/_next/static/runtime/main-31ba2a71e4a52253b2d5.module.js"
as="script" crossorigin="anonymous" />
</head>
@@ -59,9 +59,9 @@
async="" crossorigin="anonymous" nomodule=""></script>
<script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.6544e81bc61166e45e0f.module.js"
async="" crossorigin="anonymous" type="module"></script>
- <script src="/_next/static/runtime/main-f0a7aeba24f91a93e8e7.js"
+ <script src="/_next/static/runtime/main-e20154f19e18f7fa4a76.js"
async="" crossorigin="anonymous" nomodule=""></script>
- <script src="/_next/static/runtime/main-bf090db607d67d7a250f.module.js"
+ <script src="/_next/static/runtime/main-31ba2a71e4a52253b2d5.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: 8b7f62c |
This was referenced Jan 7, 2020
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 is purely experimental for benchmark comparisons, highly recommend not using it in applications yet.