-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
separate bundle into legacy and modern bundle (#828)
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
- Loading branch information
Showing
7 changed files
with
52 additions
and
41 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<script src="{{relativePath}}/bundle.js" type="module" data-webpack-inline></script> | ||
<script src="{{relativePath}}/bundle-legacy.js" nomodule></script> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Import global polyfills | ||
import 'core-js/stable'; | ||
|
||
import * as HitchhikerJS from './js/HitchhikerJS'; | ||
window.HitchhikerJS = HitchhikerJS; | ||
|
||
// Import all SCSS | ||
import Scss from './scss/answers/_default.scss'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,5 @@ | ||
// Import global polyfills | ||
import 'core-js/stable'; | ||
import * as HitchhikerJS from './js/HitchhikerJS'; | ||
window.HitchhikerJS = HitchhikerJS; | ||
|
||
// Import all SCSS | ||
import Scss from './scss/answers/_default.scss'; | ||
|
||
// Import all JS assets | ||
import Formatters from './js/formatters'; | ||
window.Formatter = Formatters; | ||
|
||
export { Formatters }; | ||
export { getDefaultMapApiKey } from './js/default-map-api-key'; | ||
export { isStaging } from './js/is-staging'; | ||
export { isMobile } from 'is-mobile'; | ||
export { getInjectedProp } from './js/get-injected-prop'; | ||
export { isHighlighted } from './js/is-highlighted'; | ||
|
||
// Used to transfigure the page for the Overlay | ||
import Overlay from './js/overlay/answers-frame/overlay'; | ||
window.Overlay = new Overlay(); | ||
|
||
// Import code used in Collapsible Filters, and give it the alias of window.CollapsibleFilters. | ||
import CollapsibleFilters from './js/collapsible-filters'; | ||
export { CollapsibleFilters }; | ||
global.CollapsibleFilters = CollapsibleFilters; | ||
|
||
// Import custom modules which can be accessed from HitchhikerJS.CustomModules | ||
import * as CustomModules from './js/custom-modules'; | ||
export { CustomModules }; | ||
|
||
import StorageKeys from './js/constants/storage-keys'; | ||
export { StorageKeys }; | ||
|
||
import transformFacets from './js/transform-facets'; | ||
export { transformFacets } | ||
import Scss from './scss/answers/_default.scss'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Import all JS assets | ||
import Formatters from './formatters'; | ||
window.Formatter = Formatters; | ||
|
||
export { Formatters }; | ||
export { getDefaultMapApiKey } from './default-map-api-key'; | ||
export { isStaging } from './is-staging'; | ||
export { isMobile } from 'is-mobile'; | ||
export { getInjectedProp } from './get-injected-prop'; | ||
export { isHighlighted } from './is-highlighted'; | ||
|
||
// Used to transfigure the page for the Overlay | ||
import Overlay from './overlay/answers-frame/overlay'; | ||
window.Overlay = new Overlay(); | ||
|
||
// Import code used in Collapsible Filters, and give it the alias of window.CollapsibleFilters. | ||
import CollapsibleFilters from './collapsible-filters'; | ||
export { CollapsibleFilters }; | ||
global.CollapsibleFilters = CollapsibleFilters; | ||
|
||
// Import custom modules which can be accessed from HitchhikerJS.CustomModules | ||
import * as CustomModules from './custom-modules'; | ||
export { CustomModules }; | ||
|
||
import StorageKeys from './constants/storage-keys'; | ||
export { StorageKeys }; | ||
|
||
import transformFacets from './transform-facets'; | ||
export { transformFacets } |
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
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