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

separate bundle into legacy and modern bundle #828

Merged
merged 3 commits into from
Jun 14, 2021

Conversation

oshi97
Copy link
Contributor

@oshi97 oshi97 commented Jun 10, 2021

This commit separates bundle.js into the polyfill-free
bundle.js and polyfilled bundle-legacy.js. Both still
run through the babel loader, because the esbuild minifier
is set to target es5, and does not let you minify some
bundles to es5 and some bundles to newer javascript.

The type="module" and nomodule script loading pattern is used
to dynamically load the correct bundle. This is the pattern we
use for determining whether to use answers-modern or answers
assets. This shrinks bundle.js from 443KB to 313KB in prod mode
(and from 1.3MB to 705KB in dev mode). In prod mode the page speed
went from 50 -> 56, and in dev mode the page speed lighthouse scores
went from 36 -> 48.

J=SLAP-1373
TEST=manual

see ~0.7s build speed improvements on yanswers and answers-atlanticsearch
when I remove the core-js import from entry.js
this build speedup doesn't show up for the test-site for some reason, though
investigated for a while but could not figure out why
I figured that yanswers and another random repo would be better benchmarks, though
the test-site's build speed was also not hurt at all by this change

see that the production modern bundle shrinks from 443KB to 313KB after removing
polyfills

smoke test that full page map on ie11 (browserstack), firefox, safari, chrome, and
galaxy s6 chrome (browserstack)

see that bundle.js is inlined properly, and only the modern one is inlined

@coveralls
Copy link

coveralls commented Jun 10, 2021

Coverage Status

Coverage decreased (-0.001%) to 5.525% when pulling f73b6a9 on dev/legacy-and-modern-bundle into 6368b08 on feature/webpack-optimizations.

layouts/html.hbs Outdated
@@ -85,7 +85,8 @@
});
{{/babel}}
</script>
<script src="{{relativePath}}/bundle.js" data-webpack-inline></script>
<script src="{{relativePath}}/bundle.js" type="module" data-webpack-inline></script>
<script src="{{relativePath}}/bundle-legacy.js" nomodule></script>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we might need to chat with Product about this change. It has some significant upgrade implications. If somebody has forked html.hbs, their site will stop working in IE11 if they're not careful during the upgrade. The bundle.js asset no longer points to the same thing post-upgrade.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

talked to Rose and she gave the ok! people who overrode html.hbs will have to refresh their html.hbs anyways for the dev sdk branch change

@oshi97 oshi97 requested a review from tmeyer2115 June 14, 2021 15:34
oshi97 added 3 commits June 14, 2021 12:18
This commit separates bundle.js into the polyfill-free
bundle.js and polyfilled bundle-legacy.js. Both still
run through the babel loader, because the esbuild minifier
is set to target es5, and does not let you minify some
bundles to es5 and some bundles to newer javascript.

The type="module" and nomodule script loading pattern is used
to dynamically load the correct bundle. This is the pattern we
use for determining whether to use answers-modern or answers
assets.

J=SLAP-1373
TEST=manual

see ~0.8s build speed improvements on yanswers and answers-atlanticsearch
when I remove the core-js import from entry.js
this build speedup doesn't show up for the test-site for some reason, though
investigated for a while but could not figure out why

see that the production modern bundle shrinks from 443KB to 313KB after removing
polyfills

smoke test that full page map on ie11 (browserstack), firefox, safari, chrome, and
galaxy s6 chrome (browserstack)
@oshi97 oshi97 force-pushed the dev/legacy-and-modern-bundle branch from c0c2214 to f73b6a9 Compare June 14, 2021 16:18
Copy link
Collaborator

@tmeyer2115 tmeyer2115 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might mention to Rose that people who forked static/entry.js will not see the performance benefit unless they update their fork.

@oshi97 oshi97 merged commit 5e08a2a into feature/webpack-optimizations Jun 14, 2021
@oshi97 oshi97 deleted the dev/legacy-and-modern-bundle branch June 14, 2021 17:19
oshi97 added a commit that referenced this pull request Jun 14, 2021
@cea2aj cea2aj mentioned this pull request Jun 22, 2021
cea2aj added a commit that referenced this pull request Jun 29, 2021
Improve development build time and web performance by adding a button legacy build

Create a legacy bundle build similar to #828 so that we can avoid the ponyfills and polyfills for modern web browsers. This yeids the following benefits:
- Improved webpack build time by about 13% from 4.5 seconds to 4 seconds when IS_DEVELOPMENT_PREVIEW=true
- Modern browsers are served a much smaller overlay-button bundle (32KB rather than the 211KB of the legacy bundle)

Since specifying type="module" on the  modern bundle makes it deferred, we must wait for DOMContentLoaded before trying to access `window.OverlayButtonJS`

J=SLAP-1417
TEST=manual

Smoke test the overlay on chrome and on IE11 on browserstack.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants