-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Update head-manager to compress better #10687
Merged
timneutkens
merged 3 commits into
vercel:canary
from
timneutkens:add/smaller-head-manager
Feb 26, 2020
Merged
Update head-manager to compress better #10687
timneutkens
merged 3 commits into
vercel:canary
from
timneutkens:add/smaller-head-manager
Feb 26, 2020
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 Overall increase
|
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
index.html gzip | 924 B | 927 B | |
link.html gzip | 934 B | 933 B | -1 B |
withRouter.html gzip | 922 B | 924 B | |
Overall change | 2.78 kB | 2.78 kB |
Diffs
Diff for index.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/index.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-c9664a5701b81faee243.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next">Hello world 👋</div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-128332ad42b64a46bb49.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-c9664a5701b81faee243.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/index.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-719bf0601e07a5098759.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next">Hello world 👋</div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-58c50e4ee070feb4fb74.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-719bf0601e07a5098759.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Diff for main-HASH.module.js
@@ -24,7 +24,7 @@ window.next = next;
exports.__esModule = true;
-exports.default = void 0;
+exports.default = initHeadManager;
var DOMAttributeNames = {
acceptCharset: 'accept-charset',
className: 'class',
@@ -32,82 +32,6 @@ var DOMAttributeNames = {
httpEquiv: 'http-equiv'
};
-class HeadManager {
- constructor() {
- this.updateHead = head => {
- var promise = this.updatePromise = Promise.resolve().then(() => {
- if (promise !== this.updatePromise) return;
- this.updatePromise = null;
- this.doUpdateHead(head);
- });
- };
-
- this.updatePromise = null;
- }
-
- doUpdateHead(head) {
- var tags = {};
- head.forEach(h => {
- var components = tags[h.type] || [];
- components.push(h);
- tags[h.type] = components;
- });
- this.updateTitle(tags.title ? tags.title[0] : null);
- var types = ['meta', 'base', 'link', 'style', 'script'];
- types.forEach(type => {
- this.updateElements(type, tags[type] || []);
- });
- }
-
- updateTitle(component) {
- var title = '';
-
- if (component) {
- var {
- children
- } = component.props;
- title = typeof children === 'string' ? children : children.join('');
- }
-
- if (title !== document.title) document.title = title;
- }
-
- updateElements(type, components) {
- var headEl = document.getElementsByTagName('head')[0];
- var headCountEl = headEl.querySelector('meta[name=next-head-count]');
-
- if (false) {}
-
- var headCount = Number(headCountEl.content);
- var oldTags = [];
-
- for (var i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = j.previousElementSibling) {
- if (j.tagName.toLowerCase() === type) {
- oldTags.push(j);
- }
- }
-
- var newTags = components.map(reactElementToDOM).filter(newTag => {
- for (var k = 0, len = oldTags.length; k < len; k++) {
- var oldTag = oldTags[k];
-
- if (oldTag.isEqualNode(newTag)) {
- oldTags.splice(k, 1);
- return false;
- }
- }
-
- return true;
- });
- oldTags.forEach(t => t.parentNode.removeChild(t));
- newTags.forEach(t => headEl.insertBefore(t, headCountEl));
- headCountEl.content = (headCount - oldTags.length + newTags.length).toString();
- }
-
-}
-
-exports.default = HeadManager;
-
function reactElementToDOM(_ref) {
var {
type,
@@ -138,6 +62,68 @@ function reactElementToDOM(_ref) {
return el;
}
+function updateElements(type, components) {
+ var headEl = document.getElementsByTagName('head')[0];
+ var headCountEl = headEl.querySelector('meta[name=next-head-count]');
+
+ if (false) {}
+
+ var headCount = Number(headCountEl.content);
+ var oldTags = [];
+
+ for (var i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = j.previousElementSibling) {
+ if (j.tagName.toLowerCase() === type) {
+ oldTags.push(j);
+ }
+ }
+
+ var newTags = components.map(reactElementToDOM).filter(newTag => {
+ for (var k = 0, len = oldTags.length; k < len; k++) {
+ var oldTag = oldTags[k];
+
+ if (oldTag.isEqualNode(newTag)) {
+ oldTags.splice(k, 1);
+ return false;
+ }
+ }
+
+ return true;
+ });
+ oldTags.forEach(t => t.parentNode.removeChild(t));
+ newTags.forEach(t => headEl.insertBefore(t, headCountEl));
+ headCountEl.content = (headCount - oldTags.length + newTags.length).toString();
+}
+
+function initHeadManager() {
+ var updatePromise = null;
+ return head => {
+ var promise = updatePromise = Promise.resolve().then(() => {
+ if (promise !== updatePromise) return;
+ updatePromise = null;
+ var tags = {};
+ head.forEach(h => {
+ var components = tags[h.type] || [];
+ components.push(h);
+ tags[h.type] = components;
+ });
+ var titleComponent = tags.title ? tags.title[0] : null;
+ var title = '';
+
+ if (titleComponent) {
+ var {
+ children
+ } = titleComponent.props;
+ title = typeof children === 'string' ? children : children.join('');
+ }
+
+ if (title !== document.title) document.title = title;
+ ['meta', 'base', 'link', 'style', 'script'].forEach(type => {
+ updateElements(type, tags[type] || []);
+ });
+ });
+ };
+}
+
/***/ }),
/***/ "FYa8":
@@ -255,7 +241,7 @@ if (window.__NEXT_P) {
window.__NEXT_P = [];
window.__NEXT_P.push = register;
-var headManager = new _headManager.default();
+var updateHead = (0, _headManager.default)();
var appElement = document.getElementById('__next');
var lastAppProps;
var webpackHMR;
@@ -565,7 +551,7 @@ function AppContainer(_ref4) {
}, _react.default.createElement(_routerContext.RouterContext.Provider, {
value: (0, _router.makePublicRouterInstance)(router)
}, _react.default.createElement(_headManagerContext.HeadManagerContext.Provider, {
- value: headManager.updateHead
+ value: updateHead
}, children)));
}
Diff for main-HASH.js
@@ -47,12 +47,8 @@ window.next = next;
"use strict";
-var _classCallCheck = __webpack_require__("lwsE");
-
-var _createClass = __webpack_require__("W8MJ");
-
exports.__esModule = true;
-exports["default"] = void 0;
+exports["default"] = initHeadManager;
var DOMAttributeNames = {
acceptCharset: 'accept-charset',
className: 'class',
@@ -60,99 +56,6 @@ var DOMAttributeNames = {
httpEquiv: 'http-equiv'
};
-var HeadManager =
-/*#__PURE__*/
-function () {
- function HeadManager() {
- var _this = this;
-
- _classCallCheck(this, HeadManager);
-
- this.updateHead = function (head) {
- var promise = _this.updatePromise = Promise.resolve().then(function () {
- if (promise !== _this.updatePromise) return;
- _this.updatePromise = null;
-
- _this.doUpdateHead(head);
- });
- };
-
- this.updatePromise = null;
- }
-
- _createClass(HeadManager, [{
- key: "doUpdateHead",
- value: function doUpdateHead(head) {
- var _this2 = this;
-
- var tags = {};
- head.forEach(function (h) {
- var components = tags[h.type] || [];
- components.push(h);
- tags[h.type] = components;
- });
- this.updateTitle(tags.title ? tags.title[0] : null);
- var types = ['meta', 'base', 'link', 'style', 'script'];
- types.forEach(function (type) {
- _this2.updateElements(type, tags[type] || []);
- });
- }
- }, {
- key: "updateTitle",
- value: function updateTitle(component) {
- var title = '';
-
- if (component) {
- var children = component.props.children;
- title = typeof children === 'string' ? children : children.join('');
- }
-
- if (title !== document.title) document.title = title;
- }
- }, {
- key: "updateElements",
- value: function updateElements(type, components) {
- var headEl = document.getElementsByTagName('head')[0];
- var headCountEl = headEl.querySelector('meta[name=next-head-count]');
-
- if (false) {}
-
- var headCount = Number(headCountEl.content);
- var oldTags = [];
-
- for (var i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = j.previousElementSibling) {
- if (j.tagName.toLowerCase() === type) {
- oldTags.push(j);
- }
- }
-
- var newTags = components.map(reactElementToDOM).filter(function (newTag) {
- for (var k = 0, len = oldTags.length; k < len; k++) {
- var oldTag = oldTags[k];
-
- if (oldTag.isEqualNode(newTag)) {
- oldTags.splice(k, 1);
- return false;
- }
- }
-
- return true;
- });
- oldTags.forEach(function (t) {
- return t.parentNode.removeChild(t);
- });
- newTags.forEach(function (t) {
- return headEl.insertBefore(t, headCountEl);
- });
- headCountEl.content = (headCount - oldTags.length + newTags.length).toString();
- }
- }]);
-
- return HeadManager;
-}();
-
-exports["default"] = HeadManager;
-
function reactElementToDOM(_ref) {
var type = _ref.type,
props = _ref.props;
@@ -179,6 +82,70 @@ function reactElementToDOM(_ref) {
return el;
}
+function updateElements(type, components) {
+ var headEl = document.getElementsByTagName('head')[0];
+ var headCountEl = headEl.querySelector('meta[name=next-head-count]');
+
+ if (false) {}
+
+ var headCount = Number(headCountEl.content);
+ var oldTags = [];
+
+ for (var i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = j.previousElementSibling) {
+ if (j.tagName.toLowerCase() === type) {
+ oldTags.push(j);
+ }
+ }
+
+ var newTags = components.map(reactElementToDOM).filter(function (newTag) {
+ for (var k = 0, len = oldTags.length; k < len; k++) {
+ var oldTag = oldTags[k];
+
+ if (oldTag.isEqualNode(newTag)) {
+ oldTags.splice(k, 1);
+ return false;
+ }
+ }
+
+ return true;
+ });
+ oldTags.forEach(function (t) {
+ return t.parentNode.removeChild(t);
+ });
+ newTags.forEach(function (t) {
+ return headEl.insertBefore(t, headCountEl);
+ });
+ headCountEl.content = (headCount - oldTags.length + newTags.length).toString();
+}
+
+function initHeadManager() {
+ var updatePromise = null;
+ return function (head) {
+ var promise = updatePromise = Promise.resolve().then(function () {
+ if (promise !== updatePromise) return;
+ updatePromise = null;
+ var tags = {};
+ head.forEach(function (h) {
+ var components = tags[h.type] || [];
+ components.push(h);
+ tags[h.type] = components;
+ });
+ var titleComponent = tags.title ? tags.title[0] : null;
+ var title = '';
+
+ if (titleComponent) {
+ var children = titleComponent.props.children;
+ title = typeof children === 'string' ? children : children.join('');
+ }
+
+ if (title !== document.title) document.title = title;
+ ['meta', 'base', 'link', 'style', 'script'].forEach(function (type) {
+ updateElements(type, tags[type] || []);
+ });
+ });
+ };
+}
+
/***/ }),
/***/ "FYa8":
@@ -311,7 +278,7 @@ if (window.__NEXT_P) {
window.__NEXT_P = [];
window.__NEXT_P.push = register;
-var headManager = new _headManager["default"]();
+var updateHead = (0, _headManager["default"])();
var appElement = document.getElementById('__next');
var lastAppProps;
var webpackHMR;
@@ -757,7 +724,7 @@ function AppContainer(_ref4) {
}, _react["default"].createElement(_routerContext.RouterContext.Provider, {
value: (0, _router.makePublicRouterInstance)(router)
}, _react["default"].createElement(_headManagerContext.HeadManagerContext.Provider, {
- value: headManager.updateHead
+ value: updateHead
}, children)));
}
Diff for link.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/link.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-c9664a5701b81faee243.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div><h3>A Link page!</h3><a href="/">Go to /</a></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/link","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-128332ad42b64a46bb49.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-c9664a5701b81faee243.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/link.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-719bf0601e07a5098759.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div><h3>A Link page!</h3><a href="/">Go to /</a></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/link","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-58c50e4ee070feb4fb74.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-719bf0601e07a5098759.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Diff for withRouter.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/withRouter.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-c9664a5701b81faee243.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div>I use withRouter</div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/withRouter","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-128332ad42b64a46bb49.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-c9664a5701b81faee243.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/withRouter.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-719bf0601e07a5098759.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div>I use withRouter</div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/withRouter","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-58c50e4ee070feb4fb74.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-719bf0601e07a5098759.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Serverless Mode (Increase detected ⚠️ )
General Overall decrease ✓
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
buildDuration | 10.6s | 10.4s | -206ms |
nodeModulesSize | 56.2 MB | 56.2 MB | -336 B |
Client Bundles (main, webpack, commons) Overall decrease ✓
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
main-HASH.js gzip | 5.05 kB | 4.98 kB | -69 B |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..b61f.js gzip | 12.3 kB | 12.3 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 57.2 kB | 57.1 kB | -69 B |
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
main-HASH.module.js gzip | 4.14 kB | 4.1 kB | -36 B |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..dule.js gzip | 9.22 kB | 9.22 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 53.2 kB | 53.2 kB | -36 B |
Legacy Client Bundles (polyfills)
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 18.9 kB | 18.9 kB | ✓ |
Overall change | 18.9 kB | 18.9 kB | ✓ |
Client Pages
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
_app.js gzip | 1.06 kB | 1.06 kB | ✓ |
_error.js gzip | 2.98 kB | 2.98 kB | ✓ |
hooks.js gzip | 664 B | 664 B | ✓ |
index.js gzip | 222 B | 222 B | ✓ |
link.js gzip | 1.9 kB | 1.9 kB | ✓ |
routerDirect.js gzip | 279 B | 279 B | ✓ |
withRouter.js gzip | 278 B | 278 B | ✓ |
Overall change | 7.38 kB | 7.38 kB | ✓ |
Client Pages Modern
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
_app.module.js gzip | 577 B | 577 B | ✓ |
_error.module.js gzip | 2.08 kB | 2.08 kB | ✓ |
hooks.module.js gzip | 370 B | 370 B | ✓ |
index.module.js gzip | 212 B | 212 B | ✓ |
link.module.js gzip | 1.48 kB | 1.48 kB | ✓ |
routerDirect..dule.js gzip | 271 B | 271 B | ✓ |
withRouter.m..dule.js gzip | 270 B | 270 B | ✓ |
Overall change | 5.26 kB | 5.26 kB | ✓ |
Client Build Manifests
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
_buildManifest.js gzip | 61 B | 61 B | ✓ |
_buildManife..dule.js gzip | 61 B | 61 B | ✓ |
Overall change | 122 B | 122 B | ✓ |
Serverless bundles Overall increase ⚠️
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
_error.js gzip | 289 kB | 289 kB | -156 B |
404.html gzip | 1.33 kB | 1.33 kB | |
hooks.html gzip | 963 B | 964 B | |
index.js gzip | 289 kB | 290 kB | |
link.js gzip | 298 kB | 297 kB | -144 B |
routerDirect.js gzip | 296 kB | 297 kB | |
withRouter.js gzip | 296 kB | 296 kB | -72 B |
Overall change | 1.47 MB | 1.47 MB |
Commit: 388d228
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 Overall increase
|
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
index.html gzip | 924 B | 927 B | |
link.html gzip | 934 B | 933 B | -1 B |
withRouter.html gzip | 922 B | 924 B | |
Overall change | 2.78 kB | 2.78 kB |
Diffs
Diff for index.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/index.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-c9664a5701b81faee243.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next">Hello world 👋</div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-128332ad42b64a46bb49.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-c9664a5701b81faee243.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/index.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-719bf0601e07a5098759.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next">Hello world 👋</div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-58c50e4ee070feb4fb74.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-719bf0601e07a5098759.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Diff for main-HASH.module.js
@@ -24,7 +24,7 @@ window.next = next;
exports.__esModule = true;
-exports.default = void 0;
+exports.default = initHeadManager;
var DOMAttributeNames = {
acceptCharset: 'accept-charset',
className: 'class',
@@ -32,82 +32,6 @@ var DOMAttributeNames = {
httpEquiv: 'http-equiv'
};
-class HeadManager {
- constructor() {
- this.updateHead = head => {
- var promise = this.updatePromise = Promise.resolve().then(() => {
- if (promise !== this.updatePromise) return;
- this.updatePromise = null;
- this.doUpdateHead(head);
- });
- };
-
- this.updatePromise = null;
- }
-
- doUpdateHead(head) {
- var tags = {};
- head.forEach(h => {
- var components = tags[h.type] || [];
- components.push(h);
- tags[h.type] = components;
- });
- this.updateTitle(tags.title ? tags.title[0] : null);
- var types = ['meta', 'base', 'link', 'style', 'script'];
- types.forEach(type => {
- this.updateElements(type, tags[type] || []);
- });
- }
-
- updateTitle(component) {
- var title = '';
-
- if (component) {
- var {
- children
- } = component.props;
- title = typeof children === 'string' ? children : children.join('');
- }
-
- if (title !== document.title) document.title = title;
- }
-
- updateElements(type, components) {
- var headEl = document.getElementsByTagName('head')[0];
- var headCountEl = headEl.querySelector('meta[name=next-head-count]');
-
- if (false) {}
-
- var headCount = Number(headCountEl.content);
- var oldTags = [];
-
- for (var i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = j.previousElementSibling) {
- if (j.tagName.toLowerCase() === type) {
- oldTags.push(j);
- }
- }
-
- var newTags = components.map(reactElementToDOM).filter(newTag => {
- for (var k = 0, len = oldTags.length; k < len; k++) {
- var oldTag = oldTags[k];
-
- if (oldTag.isEqualNode(newTag)) {
- oldTags.splice(k, 1);
- return false;
- }
- }
-
- return true;
- });
- oldTags.forEach(t => t.parentNode.removeChild(t));
- newTags.forEach(t => headEl.insertBefore(t, headCountEl));
- headCountEl.content = (headCount - oldTags.length + newTags.length).toString();
- }
-
-}
-
-exports.default = HeadManager;
-
function reactElementToDOM(_ref) {
var {
type,
@@ -138,6 +62,68 @@ function reactElementToDOM(_ref) {
return el;
}
+function updateElements(type, components) {
+ var headEl = document.getElementsByTagName('head')[0];
+ var headCountEl = headEl.querySelector('meta[name=next-head-count]');
+
+ if (false) {}
+
+ var headCount = Number(headCountEl.content);
+ var oldTags = [];
+
+ for (var i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = j.previousElementSibling) {
+ if (j.tagName.toLowerCase() === type) {
+ oldTags.push(j);
+ }
+ }
+
+ var newTags = components.map(reactElementToDOM).filter(newTag => {
+ for (var k = 0, len = oldTags.length; k < len; k++) {
+ var oldTag = oldTags[k];
+
+ if (oldTag.isEqualNode(newTag)) {
+ oldTags.splice(k, 1);
+ return false;
+ }
+ }
+
+ return true;
+ });
+ oldTags.forEach(t => t.parentNode.removeChild(t));
+ newTags.forEach(t => headEl.insertBefore(t, headCountEl));
+ headCountEl.content = (headCount - oldTags.length + newTags.length).toString();
+}
+
+function initHeadManager() {
+ var updatePromise = null;
+ return head => {
+ var promise = updatePromise = Promise.resolve().then(() => {
+ if (promise !== updatePromise) return;
+ updatePromise = null;
+ var tags = {};
+ head.forEach(h => {
+ var components = tags[h.type] || [];
+ components.push(h);
+ tags[h.type] = components;
+ });
+ var titleComponent = tags.title ? tags.title[0] : null;
+ var title = '';
+
+ if (titleComponent) {
+ var {
+ children
+ } = titleComponent.props;
+ title = typeof children === 'string' ? children : children.join('');
+ }
+
+ if (title !== document.title) document.title = title;
+ ['meta', 'base', 'link', 'style', 'script'].forEach(type => {
+ updateElements(type, tags[type] || []);
+ });
+ });
+ };
+}
+
/***/ }),
/***/ "FYa8":
@@ -255,7 +241,7 @@ if (window.__NEXT_P) {
window.__NEXT_P = [];
window.__NEXT_P.push = register;
-var headManager = new _headManager.default();
+var updateHead = (0, _headManager.default)();
var appElement = document.getElementById('__next');
var lastAppProps;
var webpackHMR;
@@ -565,7 +551,7 @@ function AppContainer(_ref4) {
}, _react.default.createElement(_routerContext.RouterContext.Provider, {
value: (0, _router.makePublicRouterInstance)(router)
}, _react.default.createElement(_headManagerContext.HeadManagerContext.Provider, {
- value: headManager.updateHead
+ value: updateHead
}, children)));
}
Diff for main-HASH.js
@@ -47,12 +47,8 @@ window.next = next;
"use strict";
-var _classCallCheck = __webpack_require__("lwsE");
-
-var _createClass = __webpack_require__("W8MJ");
-
exports.__esModule = true;
-exports["default"] = void 0;
+exports["default"] = initHeadManager;
var DOMAttributeNames = {
acceptCharset: 'accept-charset',
className: 'class',
@@ -60,99 +56,6 @@ var DOMAttributeNames = {
httpEquiv: 'http-equiv'
};
-var HeadManager =
-/*#__PURE__*/
-function () {
- function HeadManager() {
- var _this = this;
-
- _classCallCheck(this, HeadManager);
-
- this.updateHead = function (head) {
- var promise = _this.updatePromise = Promise.resolve().then(function () {
- if (promise !== _this.updatePromise) return;
- _this.updatePromise = null;
-
- _this.doUpdateHead(head);
- });
- };
-
- this.updatePromise = null;
- }
-
- _createClass(HeadManager, [{
- key: "doUpdateHead",
- value: function doUpdateHead(head) {
- var _this2 = this;
-
- var tags = {};
- head.forEach(function (h) {
- var components = tags[h.type] || [];
- components.push(h);
- tags[h.type] = components;
- });
- this.updateTitle(tags.title ? tags.title[0] : null);
- var types = ['meta', 'base', 'link', 'style', 'script'];
- types.forEach(function (type) {
- _this2.updateElements(type, tags[type] || []);
- });
- }
- }, {
- key: "updateTitle",
- value: function updateTitle(component) {
- var title = '';
-
- if (component) {
- var children = component.props.children;
- title = typeof children === 'string' ? children : children.join('');
- }
-
- if (title !== document.title) document.title = title;
- }
- }, {
- key: "updateElements",
- value: function updateElements(type, components) {
- var headEl = document.getElementsByTagName('head')[0];
- var headCountEl = headEl.querySelector('meta[name=next-head-count]');
-
- if (false) {}
-
- var headCount = Number(headCountEl.content);
- var oldTags = [];
-
- for (var i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = j.previousElementSibling) {
- if (j.tagName.toLowerCase() === type) {
- oldTags.push(j);
- }
- }
-
- var newTags = components.map(reactElementToDOM).filter(function (newTag) {
- for (var k = 0, len = oldTags.length; k < len; k++) {
- var oldTag = oldTags[k];
-
- if (oldTag.isEqualNode(newTag)) {
- oldTags.splice(k, 1);
- return false;
- }
- }
-
- return true;
- });
- oldTags.forEach(function (t) {
- return t.parentNode.removeChild(t);
- });
- newTags.forEach(function (t) {
- return headEl.insertBefore(t, headCountEl);
- });
- headCountEl.content = (headCount - oldTags.length + newTags.length).toString();
- }
- }]);
-
- return HeadManager;
-}();
-
-exports["default"] = HeadManager;
-
function reactElementToDOM(_ref) {
var type = _ref.type,
props = _ref.props;
@@ -179,6 +82,70 @@ function reactElementToDOM(_ref) {
return el;
}
+function updateElements(type, components) {
+ var headEl = document.getElementsByTagName('head')[0];
+ var headCountEl = headEl.querySelector('meta[name=next-head-count]');
+
+ if (false) {}
+
+ var headCount = Number(headCountEl.content);
+ var oldTags = [];
+
+ for (var i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = j.previousElementSibling) {
+ if (j.tagName.toLowerCase() === type) {
+ oldTags.push(j);
+ }
+ }
+
+ var newTags = components.map(reactElementToDOM).filter(function (newTag) {
+ for (var k = 0, len = oldTags.length; k < len; k++) {
+ var oldTag = oldTags[k];
+
+ if (oldTag.isEqualNode(newTag)) {
+ oldTags.splice(k, 1);
+ return false;
+ }
+ }
+
+ return true;
+ });
+ oldTags.forEach(function (t) {
+ return t.parentNode.removeChild(t);
+ });
+ newTags.forEach(function (t) {
+ return headEl.insertBefore(t, headCountEl);
+ });
+ headCountEl.content = (headCount - oldTags.length + newTags.length).toString();
+}
+
+function initHeadManager() {
+ var updatePromise = null;
+ return function (head) {
+ var promise = updatePromise = Promise.resolve().then(function () {
+ if (promise !== updatePromise) return;
+ updatePromise = null;
+ var tags = {};
+ head.forEach(function (h) {
+ var components = tags[h.type] || [];
+ components.push(h);
+ tags[h.type] = components;
+ });
+ var titleComponent = tags.title ? tags.title[0] : null;
+ var title = '';
+
+ if (titleComponent) {
+ var children = titleComponent.props.children;
+ title = typeof children === 'string' ? children : children.join('');
+ }
+
+ if (title !== document.title) document.title = title;
+ ['meta', 'base', 'link', 'style', 'script'].forEach(function (type) {
+ updateElements(type, tags[type] || []);
+ });
+ });
+ };
+}
+
/***/ }),
/***/ "FYa8":
@@ -311,7 +278,7 @@ if (window.__NEXT_P) {
window.__NEXT_P = [];
window.__NEXT_P.push = register;
-var headManager = new _headManager["default"]();
+var updateHead = (0, _headManager["default"])();
var appElement = document.getElementById('__next');
var lastAppProps;
var webpackHMR;
@@ -757,7 +724,7 @@ function AppContainer(_ref4) {
}, _react["default"].createElement(_routerContext.RouterContext.Provider, {
value: (0, _router.makePublicRouterInstance)(router)
}, _react["default"].createElement(_headManagerContext.HeadManagerContext.Provider, {
- value: headManager.updateHead
+ value: updateHead
}, children)));
}
Diff for link.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/link.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-c9664a5701b81faee243.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div><h3>A Link page!</h3><a href="/">Go to /</a></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/link","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-128332ad42b64a46bb49.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-c9664a5701b81faee243.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/link.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-719bf0601e07a5098759.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div><h3>A Link page!</h3><a href="/">Go to /</a></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/link","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-58c50e4ee070feb4fb74.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-719bf0601e07a5098759.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Diff for withRouter.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/withRouter.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-c9664a5701b81faee243.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div>I use withRouter</div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/withRouter","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-128332ad42b64a46bb49.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-c9664a5701b81faee243.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/withRouter.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-719bf0601e07a5098759.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div>I use withRouter</div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/withRouter","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-58c50e4ee070feb4fb74.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-719bf0601e07a5098759.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Serverless Mode (Decrease detected ✓)
General Overall decrease ✓
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
buildDuration | 10.4s | 10.4s | |
nodeModulesSize | 56.2 MB | 56.2 MB | -336 B |
Client Bundles (main, webpack, commons) Overall decrease ✓
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
main-HASH.js gzip | 5.05 kB | 4.98 kB | -69 B |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..b61f.js gzip | 12.3 kB | 12.3 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 57.2 kB | 57.1 kB | -69 B |
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
main-HASH.module.js gzip | 4.14 kB | 4.1 kB | -36 B |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..dule.js gzip | 9.22 kB | 9.22 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 53.2 kB | 53.2 kB | -36 B |
Legacy Client Bundles (polyfills)
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 18.9 kB | 18.9 kB | ✓ |
Overall change | 18.9 kB | 18.9 kB | ✓ |
Client Pages
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
_app.js gzip | 1.06 kB | 1.06 kB | ✓ |
_error.js gzip | 2.98 kB | 2.98 kB | ✓ |
hooks.js gzip | 664 B | 664 B | ✓ |
index.js gzip | 222 B | 222 B | ✓ |
link.js gzip | 1.9 kB | 1.9 kB | ✓ |
routerDirect.js gzip | 279 B | 279 B | ✓ |
withRouter.js gzip | 278 B | 278 B | ✓ |
Overall change | 7.38 kB | 7.38 kB | ✓ |
Client Pages Modern
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
_app.module.js gzip | 577 B | 577 B | ✓ |
_error.module.js gzip | 2.08 kB | 2.08 kB | ✓ |
hooks.module.js gzip | 370 B | 370 B | ✓ |
index.module.js gzip | 212 B | 212 B | ✓ |
link.module.js gzip | 1.48 kB | 1.48 kB | ✓ |
routerDirect..dule.js gzip | 271 B | 271 B | ✓ |
withRouter.m..dule.js gzip | 270 B | 270 B | ✓ |
Overall change | 5.26 kB | 5.26 kB | ✓ |
Client Build Manifests
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
_buildManifest.js gzip | 61 B | 61 B | ✓ |
_buildManife..dule.js gzip | 61 B | 61 B | ✓ |
Overall change | 122 B | 122 B | ✓ |
Serverless bundles Overall decrease ✓
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
_error.js gzip | 290 kB | 290 kB | |
404.html gzip | 1.33 kB | 1.33 kB | |
hooks.html gzip | 963 B | 964 B | |
index.js gzip | 290 kB | 290 kB | |
link.js gzip | 298 kB | 298 kB | |
routerDirect.js gzip | 297 kB | 296 kB | -171 B |
withRouter.js gzip | 298 kB | 296 kB | -1.37 kB |
Overall change | 1.47 MB | 1.47 MB | -757 B |
Commit: 9098a49
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 Overall increase
|
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
index.html gzip | 924 B | 927 B | |
link.html gzip | 934 B | 933 B | -1 B |
withRouter.html gzip | 922 B | 924 B | |
Overall change | 2.78 kB | 2.78 kB |
Diffs
Diff for link.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/link.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-c9664a5701b81faee243.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div><h3>A Link page!</h3><a href="/">Go to /</a></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/link","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-128332ad42b64a46bb49.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-c9664a5701b81faee243.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/link.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-719bf0601e07a5098759.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div><h3>A Link page!</h3><a href="/">Go to /</a></div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/link","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/link" src="/_next/static/BUILD_ID/pages/link.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-58c50e4ee070feb4fb74.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-719bf0601e07a5098759.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Diff for index.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/index.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-c9664a5701b81faee243.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next">Hello world 👋</div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-128332ad42b64a46bb49.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-c9664a5701b81faee243.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/index.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-719bf0601e07a5098759.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next">Hello world 👋</div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/" src="/_next/static/BUILD_ID/pages/index.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-58c50e4ee070feb4fb74.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-719bf0601e07a5098759.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Diff for main-HASH.module.js
@@ -24,7 +24,7 @@ window.next = next;
exports.__esModule = true;
-exports.default = void 0;
+exports.default = initHeadManager;
var DOMAttributeNames = {
acceptCharset: 'accept-charset',
className: 'class',
@@ -32,82 +32,6 @@ var DOMAttributeNames = {
httpEquiv: 'http-equiv'
};
-class HeadManager {
- constructor() {
- this.updateHead = head => {
- var promise = this.updatePromise = Promise.resolve().then(() => {
- if (promise !== this.updatePromise) return;
- this.updatePromise = null;
- this.doUpdateHead(head);
- });
- };
-
- this.updatePromise = null;
- }
-
- doUpdateHead(head) {
- var tags = {};
- head.forEach(h => {
- var components = tags[h.type] || [];
- components.push(h);
- tags[h.type] = components;
- });
- this.updateTitle(tags.title ? tags.title[0] : null);
- var types = ['meta', 'base', 'link', 'style', 'script'];
- types.forEach(type => {
- this.updateElements(type, tags[type] || []);
- });
- }
-
- updateTitle(component) {
- var title = '';
-
- if (component) {
- var {
- children
- } = component.props;
- title = typeof children === 'string' ? children : children.join('');
- }
-
- if (title !== document.title) document.title = title;
- }
-
- updateElements(type, components) {
- var headEl = document.getElementsByTagName('head')[0];
- var headCountEl = headEl.querySelector('meta[name=next-head-count]');
-
- if (false) {}
-
- var headCount = Number(headCountEl.content);
- var oldTags = [];
-
- for (var i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = j.previousElementSibling) {
- if (j.tagName.toLowerCase() === type) {
- oldTags.push(j);
- }
- }
-
- var newTags = components.map(reactElementToDOM).filter(newTag => {
- for (var k = 0, len = oldTags.length; k < len; k++) {
- var oldTag = oldTags[k];
-
- if (oldTag.isEqualNode(newTag)) {
- oldTags.splice(k, 1);
- return false;
- }
- }
-
- return true;
- });
- oldTags.forEach(t => t.parentNode.removeChild(t));
- newTags.forEach(t => headEl.insertBefore(t, headCountEl));
- headCountEl.content = (headCount - oldTags.length + newTags.length).toString();
- }
-
-}
-
-exports.default = HeadManager;
-
function reactElementToDOM(_ref) {
var {
type,
@@ -138,6 +62,68 @@ function reactElementToDOM(_ref) {
return el;
}
+function updateElements(type, components) {
+ var headEl = document.getElementsByTagName('head')[0];
+ var headCountEl = headEl.querySelector('meta[name=next-head-count]');
+
+ if (false) {}
+
+ var headCount = Number(headCountEl.content);
+ var oldTags = [];
+
+ for (var i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = j.previousElementSibling) {
+ if (j.tagName.toLowerCase() === type) {
+ oldTags.push(j);
+ }
+ }
+
+ var newTags = components.map(reactElementToDOM).filter(newTag => {
+ for (var k = 0, len = oldTags.length; k < len; k++) {
+ var oldTag = oldTags[k];
+
+ if (oldTag.isEqualNode(newTag)) {
+ oldTags.splice(k, 1);
+ return false;
+ }
+ }
+
+ return true;
+ });
+ oldTags.forEach(t => t.parentNode.removeChild(t));
+ newTags.forEach(t => headEl.insertBefore(t, headCountEl));
+ headCountEl.content = (headCount - oldTags.length + newTags.length).toString();
+}
+
+function initHeadManager() {
+ var updatePromise = null;
+ return head => {
+ var promise = updatePromise = Promise.resolve().then(() => {
+ if (promise !== updatePromise) return;
+ updatePromise = null;
+ var tags = {};
+ head.forEach(h => {
+ var components = tags[h.type] || [];
+ components.push(h);
+ tags[h.type] = components;
+ });
+ var titleComponent = tags.title ? tags.title[0] : null;
+ var title = '';
+
+ if (titleComponent) {
+ var {
+ children
+ } = titleComponent.props;
+ title = typeof children === 'string' ? children : children.join('');
+ }
+
+ if (title !== document.title) document.title = title;
+ ['meta', 'base', 'link', 'style', 'script'].forEach(type => {
+ updateElements(type, tags[type] || []);
+ });
+ });
+ };
+}
+
/***/ }),
/***/ "FYa8":
@@ -255,7 +241,7 @@ if (window.__NEXT_P) {
window.__NEXT_P = [];
window.__NEXT_P.push = register;
-var headManager = new _headManager.default();
+var updateHead = (0, _headManager.default)();
var appElement = document.getElementById('__next');
var lastAppProps;
var webpackHMR;
@@ -565,7 +551,7 @@ function AppContainer(_ref4) {
}, _react.default.createElement(_routerContext.RouterContext.Provider, {
value: (0, _router.makePublicRouterInstance)(router)
}, _react.default.createElement(_headManagerContext.HeadManagerContext.Provider, {
- value: headManager.updateHead
+ value: updateHead
}, children)));
}
Diff for main-HASH.js
@@ -47,12 +47,8 @@ window.next = next;
"use strict";
-var _classCallCheck = __webpack_require__("lwsE");
-
-var _createClass = __webpack_require__("W8MJ");
-
exports.__esModule = true;
-exports["default"] = void 0;
+exports["default"] = initHeadManager;
var DOMAttributeNames = {
acceptCharset: 'accept-charset',
className: 'class',
@@ -60,99 +56,6 @@ var DOMAttributeNames = {
httpEquiv: 'http-equiv'
};
-var HeadManager =
-/*#__PURE__*/
-function () {
- function HeadManager() {
- var _this = this;
-
- _classCallCheck(this, HeadManager);
-
- this.updateHead = function (head) {
- var promise = _this.updatePromise = Promise.resolve().then(function () {
- if (promise !== _this.updatePromise) return;
- _this.updatePromise = null;
-
- _this.doUpdateHead(head);
- });
- };
-
- this.updatePromise = null;
- }
-
- _createClass(HeadManager, [{
- key: "doUpdateHead",
- value: function doUpdateHead(head) {
- var _this2 = this;
-
- var tags = {};
- head.forEach(function (h) {
- var components = tags[h.type] || [];
- components.push(h);
- tags[h.type] = components;
- });
- this.updateTitle(tags.title ? tags.title[0] : null);
- var types = ['meta', 'base', 'link', 'style', 'script'];
- types.forEach(function (type) {
- _this2.updateElements(type, tags[type] || []);
- });
- }
- }, {
- key: "updateTitle",
- value: function updateTitle(component) {
- var title = '';
-
- if (component) {
- var children = component.props.children;
- title = typeof children === 'string' ? children : children.join('');
- }
-
- if (title !== document.title) document.title = title;
- }
- }, {
- key: "updateElements",
- value: function updateElements(type, components) {
- var headEl = document.getElementsByTagName('head')[0];
- var headCountEl = headEl.querySelector('meta[name=next-head-count]');
-
- if (false) {}
-
- var headCount = Number(headCountEl.content);
- var oldTags = [];
-
- for (var i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = j.previousElementSibling) {
- if (j.tagName.toLowerCase() === type) {
- oldTags.push(j);
- }
- }
-
- var newTags = components.map(reactElementToDOM).filter(function (newTag) {
- for (var k = 0, len = oldTags.length; k < len; k++) {
- var oldTag = oldTags[k];
-
- if (oldTag.isEqualNode(newTag)) {
- oldTags.splice(k, 1);
- return false;
- }
- }
-
- return true;
- });
- oldTags.forEach(function (t) {
- return t.parentNode.removeChild(t);
- });
- newTags.forEach(function (t) {
- return headEl.insertBefore(t, headCountEl);
- });
- headCountEl.content = (headCount - oldTags.length + newTags.length).toString();
- }
- }]);
-
- return HeadManager;
-}();
-
-exports["default"] = HeadManager;
-
function reactElementToDOM(_ref) {
var type = _ref.type,
props = _ref.props;
@@ -179,6 +82,70 @@ function reactElementToDOM(_ref) {
return el;
}
+function updateElements(type, components) {
+ var headEl = document.getElementsByTagName('head')[0];
+ var headCountEl = headEl.querySelector('meta[name=next-head-count]');
+
+ if (false) {}
+
+ var headCount = Number(headCountEl.content);
+ var oldTags = [];
+
+ for (var i = 0, j = headCountEl.previousElementSibling; i < headCount; i++, j = j.previousElementSibling) {
+ if (j.tagName.toLowerCase() === type) {
+ oldTags.push(j);
+ }
+ }
+
+ var newTags = components.map(reactElementToDOM).filter(function (newTag) {
+ for (var k = 0, len = oldTags.length; k < len; k++) {
+ var oldTag = oldTags[k];
+
+ if (oldTag.isEqualNode(newTag)) {
+ oldTags.splice(k, 1);
+ return false;
+ }
+ }
+
+ return true;
+ });
+ oldTags.forEach(function (t) {
+ return t.parentNode.removeChild(t);
+ });
+ newTags.forEach(function (t) {
+ return headEl.insertBefore(t, headCountEl);
+ });
+ headCountEl.content = (headCount - oldTags.length + newTags.length).toString();
+}
+
+function initHeadManager() {
+ var updatePromise = null;
+ return function (head) {
+ var promise = updatePromise = Promise.resolve().then(function () {
+ if (promise !== updatePromise) return;
+ updatePromise = null;
+ var tags = {};
+ head.forEach(function (h) {
+ var components = tags[h.type] || [];
+ components.push(h);
+ tags[h.type] = components;
+ });
+ var titleComponent = tags.title ? tags.title[0] : null;
+ var title = '';
+
+ if (titleComponent) {
+ var children = titleComponent.props.children;
+ title = typeof children === 'string' ? children : children.join('');
+ }
+
+ if (title !== document.title) document.title = title;
+ ['meta', 'base', 'link', 'style', 'script'].forEach(function (type) {
+ updateElements(type, tags[type] || []);
+ });
+ });
+ };
+}
+
/***/ }),
/***/ "FYa8":
@@ -311,7 +278,7 @@ if (window.__NEXT_P) {
window.__NEXT_P = [];
window.__NEXT_P.push = register;
-var headManager = new _headManager["default"]();
+var updateHead = (0, _headManager["default"])();
var appElement = document.getElementById('__next');
var lastAppProps;
var webpackHMR;
@@ -757,7 +724,7 @@ function AppContainer(_ref4) {
}, _react["default"].createElement(_routerContext.RouterContext.Provider, {
value: (0, _router.makePublicRouterInstance)(router)
}, _react["default"].createElement(_headManagerContext.HeadManagerContext.Provider, {
- value: headManager.updateHead
+ value: updateHead
}, children)));
}
Diff for withRouter.html
@@ -1 +1 @@
-<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/withRouter.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-c9664a5701b81faee243.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div>I use withRouter</div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/withRouter","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-128332ad42b64a46bb49.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-c9664a5701b81faee243.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
+<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/BUILD_ID/pages/withRouter.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/BUILD_ID/pages/_app.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" as="script" crossorigin="anonymous"/><link rel="preload" href="/_next/static/runtime/main-719bf0601e07a5098759.module.js" as="script" crossorigin="anonymous"/></head><body><div id="__next"><div>I use withRouter</div></div><script id="__NEXT_DATA__" type="application/json" crossorigin="anonymous">{"props":{"pageProps":{}},"page":"/withRouter","query":{},"buildId":"BUILD_ID","isFallback":false}</script><script crossorigin="anonymous" nomodule="">!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script crossorigin="anonymous" nomodule="" src="/_next/static/runtime/polyfills-bd6f9cd8c6e94d80734a.js"></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/withRouter" src="/_next/static/BUILD_ID/pages/withRouter.module.js" crossorigin="anonymous" type="module"></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.js" crossorigin="anonymous" nomodule=""></script><script async="" data-next-page="/_app" src="/_next/static/BUILD_ID/pages/_app.module.js" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/webpack-4d739ac7b0d8f888ab18.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/webpack-d629b83a65f3e33fa99e.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/framework.5bb7f30f859f5f31359f.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.e73c39e0853e212c84a2.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/chunks/de003c3a9d308750aa009870a5926f9b18ab31f4.3a575ad58307227b7943.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/runtime/main-58c50e4ee070feb4fb74.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/runtime/main-719bf0601e07a5098759.module.js" async="" crossorigin="anonymous" type="module"></script><script src="/_next/static/BUILD_ID/_buildManifest.js" async="" crossorigin="anonymous" nomodule=""></script><script src="/_next/static/BUILD_ID/_buildManifest.module.js" async="" crossorigin="anonymous" type="module"></script></body></html>
\ No newline at end of file
Serverless Mode (Decrease detected ✓)
General Overall decrease ✓
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
buildDuration | 10.2s | 10.5s | |
nodeModulesSize | 56.2 MB | 56.2 MB | -336 B |
Client Bundles (main, webpack, commons) Overall decrease ✓
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
main-HASH.js gzip | 5.05 kB | 4.98 kB | -69 B |
webpack-HASH.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..b61f.js gzip | 12.3 kB | 12.3 kB | ✓ |
framework.HASH.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 57.2 kB | 57.1 kB | -69 B |
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
main-HASH.module.js gzip | 4.14 kB | 4.1 kB | -36 B |
webpack-HASH..dule.js gzip | 746 B | 746 B | ✓ |
de003c3a9d30..dule.js gzip | 9.22 kB | 9.22 kB | ✓ |
framework.HA..dule.js gzip | 39.1 kB | 39.1 kB | ✓ |
Overall change | 53.2 kB | 53.2 kB | -36 B |
Legacy Client Bundles (polyfills)
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 18.9 kB | 18.9 kB | ✓ |
Overall change | 18.9 kB | 18.9 kB | ✓ |
Client Pages
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
_app.js gzip | 1.06 kB | 1.06 kB | ✓ |
_error.js gzip | 2.98 kB | 2.98 kB | ✓ |
hooks.js gzip | 664 B | 664 B | ✓ |
index.js gzip | 222 B | 222 B | ✓ |
link.js gzip | 1.9 kB | 1.9 kB | ✓ |
routerDirect.js gzip | 279 B | 279 B | ✓ |
withRouter.js gzip | 278 B | 278 B | ✓ |
Overall change | 7.38 kB | 7.38 kB | ✓ |
Client Pages Modern
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
_app.module.js gzip | 577 B | 577 B | ✓ |
_error.module.js gzip | 2.08 kB | 2.08 kB | ✓ |
hooks.module.js gzip | 370 B | 370 B | ✓ |
index.module.js gzip | 212 B | 212 B | ✓ |
link.module.js gzip | 1.48 kB | 1.48 kB | ✓ |
routerDirect..dule.js gzip | 271 B | 271 B | ✓ |
withRouter.m..dule.js gzip | 270 B | 270 B | ✓ |
Overall change | 5.26 kB | 5.26 kB | ✓ |
Client Build Manifests
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
_buildManifest.js gzip | 61 B | 61 B | ✓ |
_buildManife..dule.js gzip | 61 B | 61 B | ✓ |
Overall change | 122 B | 122 B | ✓ |
Serverless bundles Overall decrease ✓
zeit/next.js canary | timneutkens/next.js add/smaller-head-manager | Change | |
---|---|---|---|
_error.js gzip | 290 kB | 290 kB | -652 B |
404.html gzip | 1.33 kB | 1.33 kB | |
hooks.html gzip | 963 B | 964 B | |
index.js gzip | 290 kB | 290 kB | -199 B |
link.js gzip | 298 kB | 297 kB | -148 B |
routerDirect.js gzip | 298 kB | 297 kB | -1.26 kB |
withRouter.js gzip | 297 kB | 296 kB | -282 B |
Overall change | 1.47 MB | 1.47 MB | -2.54 kB |
Commit: 50764e4
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.
Gets rid of a few babel runtime helpers in main.