Skip to content
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

Shave a few bytes off the bootstrap code #14457

Merged
merged 1 commit into from
Jun 22, 2020

Conversation

Janpot
Copy link
Contributor

@Janpot Janpot commented Jun 22, 2020

Saw in the client bootstrap script that the error message was printed alongside the stacktrace. This is unnecessary since the stacktrace already includes the error message. In fact, it seems like browsers already do a good job of printing an error with its stacktrace when you just print them using console.error. It's a bit minor, but this should shave off a few bytes of the bundle.

@ijjk
Copy link
Member

ijjk commented Jun 22, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall decrease ✓
vercel/next.js canary Janpot/next.js bootstrap-reduce-size Change
buildDuration 10.7s 10.8s ⚠️ +61ms
nodeModulesSize 67 MB 67 MB -195 B
Page Load Tests Overall increase ✓
vercel/next.js canary Janpot/next.js bootstrap-reduce-size Change
/ failed reqs 0 0
/ total time (seconds) 1.83 1.836 ⚠️ +0.01
/ avg req/sec 1365.94 1361.5 -4.44
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.142 1.091 -0.05
/error-in-render avg req/sec 2189.93 2290.97 ⚠️ +101.04
Client Bundles (main, webpack, commons) Overall decrease ✓
vercel/next.js canary Janpot/next.js bootstrap-reduce-size Change
main-HASH.js gzip 6.53 kB 6.52 kB -16 B
webpack-HASH.js gzip 746 B 746 B
19b7e98f51cc..33d5.js gzip 10.6 kB 10.6 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57 kB 57 kB -16 B
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
vercel/next.js canary Janpot/next.js bootstrap-reduce-size Change
main-HASH.module.js gzip 5.62 kB 5.61 kB -18 B
webpack-HASH..dule.js gzip 746 B 746 B
19b7e98f51cc..dule.js gzip 6.94 kB 6.94 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.5 kB 52.4 kB -18 B
Legacy Client Bundles (polyfills)
vercel/next.js canary Janpot/next.js bootstrap-reduce-size Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Build Manifests
vercel/next.js canary Janpot/next.js bootstrap-reduce-size Change
_buildManifest.js gzip 267 B 267 B
_buildManife..dule.js gzip 272 B 272 B
Overall change 539 B 539 B
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary Janpot/next.js bootstrap-reduce-size Change
index.html gzip 955 B 954 B -1 B
link.html gzip 960 B 958 B -2 B
withRouter.html gzip 947 B 946 B -1 B
Overall change 2.86 kB 2.86 kB -4 B

Diffs

Diff for main-HASH.js
@@ -34,9 +34,7 @@
       var next = _interopRequireWildcard(__webpack_require__("IKlv"));
 
       window.next = next;
-      (0, next["default"])()["catch"](function(err) {
-        console.error("".concat(err.message, "\n").concat(err.stack));
-      });
+      (0, next["default"])()["catch"](console.error);
 
       /***/
     },
Diff for main-HASH.module.js
@@ -9,9 +9,7 @@
       var next = _interopRequireWildcard(__webpack_require__("IKlv"));
 
       window.next = next;
-      (0, next.default)().catch(err => {
-        console.error("".concat(err.message, "\n").concat(err.stack));
-      });
+      (0, next.default)().catch(console.error);
 
       /***/
     },
Diff for index.html
@@ -6,7 +6,7 @@
     <meta name="next-head-count" content="2" />
     <link
       rel="preload"
-      href="/_next/static/runtime/main-42d828ef8d8b6c5666d1.module.js"
+      href="/_next/static/runtime/main-cb730d948f120d94cc65.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -81,13 +81,13 @@
       src="/_next/static/runtime/polyfills-b9d354b83d10fbe21b38.js"
     ></script>
     <script
-      src="/_next/static/runtime/main-a25147c62d4e05016091.js"
+      src="/_next/static/runtime/main-e6bc7310f787741b6147.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/runtime/main-42d828ef8d8b6c5666d1.module.js"
+      src="/_next/static/runtime/main-cb730d948f120d94cc65.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for link.html
@@ -6,7 +6,7 @@
     <meta name="next-head-count" content="2" />
     <link
       rel="preload"
-      href="/_next/static/runtime/main-42d828ef8d8b6c5666d1.module.js"
+      href="/_next/static/runtime/main-cb730d948f120d94cc65.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -86,13 +86,13 @@
       src="/_next/static/runtime/polyfills-b9d354b83d10fbe21b38.js"
     ></script>
     <script
-      src="/_next/static/runtime/main-a25147c62d4e05016091.js"
+      src="/_next/static/runtime/main-e6bc7310f787741b6147.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/runtime/main-42d828ef8d8b6c5666d1.module.js"
+      src="/_next/static/runtime/main-cb730d948f120d94cc65.module.js"
       async=""
       crossorigin="anonymous"
       type="module"
Diff for withRouter.html
@@ -6,7 +6,7 @@
     <meta name="next-head-count" content="2" />
     <link
       rel="preload"
-      href="/_next/static/runtime/main-42d828ef8d8b6c5666d1.module.js"
+      href="/_next/static/runtime/main-cb730d948f120d94cc65.module.js"
       as="script"
       crossorigin="anonymous"
     />
@@ -81,13 +81,13 @@
       src="/_next/static/runtime/polyfills-b9d354b83d10fbe21b38.js"
     ></script>
     <script
-      src="/_next/static/runtime/main-a25147c62d4e05016091.js"
+      src="/_next/static/runtime/main-e6bc7310f787741b6147.js"
       async=""
       crossorigin="anonymous"
       nomodule=""
     ></script>
     <script
-      src="/_next/static/runtime/main-42d828ef8d8b6c5666d1.module.js"
+      src="/_next/static/runtime/main-cb730d948f120d94cc65.module.js"
       async=""
       crossorigin="anonymous"
       type="module"

Serverless Mode (Decrease detected ✓)
General Overall decrease ✓
vercel/next.js canary Janpot/next.js bootstrap-reduce-size Change
buildDuration 11.7s 11.5s -130ms
nodeModulesSize 67 MB 67 MB -195 B
Client Bundles (main, webpack, commons) Overall decrease ✓
vercel/next.js canary Janpot/next.js bootstrap-reduce-size Change
main-HASH.js gzip 6.53 kB 6.52 kB -16 B
webpack-HASH.js gzip 746 B 746 B
19b7e98f51cc..33d5.js gzip 10.6 kB 10.6 kB
framework.HASH.js gzip 39.1 kB 39.1 kB
Overall change 57 kB 57 kB -16 B
Client Bundles (main, webpack, commons) Modern Overall decrease ✓
vercel/next.js canary Janpot/next.js bootstrap-reduce-size Change
main-HASH.module.js gzip 5.62 kB 5.61 kB -18 B
webpack-HASH..dule.js gzip 746 B 746 B
19b7e98f51cc..dule.js gzip 6.94 kB 6.94 kB
framework.HA..dule.js gzip 39.1 kB 39.1 kB
Overall change 52.5 kB 52.4 kB -18 B
Legacy Client Bundles (polyfills)
vercel/next.js canary Janpot/next.js bootstrap-reduce-size Change
polyfills-HASH.js gzip 26.3 kB 26.3 kB
Overall change 26.3 kB 26.3 kB
Client Build Manifests
vercel/next.js canary Janpot/next.js bootstrap-reduce-size Change
_buildManifest.js gzip 267 B 267 B
_buildManife..dule.js gzip 272 B 272 B
Overall change 539 B 539 B
Serverless bundles
vercel/next.js canary Janpot/next.js bootstrap-reduce-size Change
_error.js 875 kB 875 kB
404.html 4.17 kB 4.17 kB
hooks.html 3.79 kB 3.79 kB
index.js 875 kB 875 kB
link.js 914 kB 914 kB
routerDirect.js 906 kB 906 kB
withRouter.js 906 kB 906 kB
Overall change 4.48 MB 4.48 MB
Commit: 821affb

@Janpot Janpot marked this pull request as ready for review June 22, 2020 17:45
@kodiakhq kodiakhq bot merged commit 7078318 into vercel:canary Jun 22, 2020
@Janpot Janpot deleted the bootstrap-reduce-size branch June 22, 2020 17:51
rokinsky pushed a commit to rokinsky/next.js that referenced this pull request Jul 11, 2020
Saw in the client bootstrap script that the error message was printed alongside the stacktrace. This is unnecessary since the stacktrace already includes the error message. In fact, it seems like browsers already do a good job of printing an error with its stacktrace when you just print them using `console.error`. It's a bit minor, but this should shave off a few bytes of the bundle.
@vercel vercel locked as resolved and limited conversation to collaborators Jan 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants