Open oandregal opened 6 years ago
Some stats to consider: https://github.com/GoogleChromeLabs/discovery/issues/1
Parsing speed on mobile (moto G4) ~1Mb per second. Source: https://youtu.be/Fg7niTmNNLg
Check optimize-js in addition to minifiers: https://github.com/nolanlawson/optimize-js/blob/master/README.md
Might contain useful info: https://medium.com/reloading/javascript-start-up-performance-69200f43b201
About bundles: different bundles for stuff that change frequently and stuff that doesn't so we can leverage the different caches in place - browsers (less network request time) and JS engines (less time to parse because they maintain a bytecode cache).
After #32 and #34 this looks a lot better for JS: it's down to 0.8KB (~0.3KB minified) from 1.8MB.
https://github.com/Automattic/happychat-client/pull/67 reduced CSS bundle from 70K to 40K.
Before
After:
https://github.com/Automattic/happychat-client/pull/155 By removing our custom Gridicon build and use the Gridicons 3 (which allows us to import icons individually) we have reduced the raw/parsed size to 390K (a -2K improvement), and the gzipped to 112K (-1K improvement).
https://github.com/Automattic/happychat-client/pull/174 reduced 10K the raw size and 3K the gzip size by not bundling certain lodash features we're not using. See.
Note that paths
and shorthands
are in use, so we've not dropped them. If we change the code to further remove those, we could reduce the raw size in 5K and the gzip size in 2K.
Before:
After:
https://github.com/Automattic/happychat-client/pull/187 has increased JS (+2K raw) and CSS (+4k raw and 2 new bundles for woo and jpop themes) bundle size. To introduce themes with CSS Custom Properties we need to polyfill for those browsers that yet don't support them.
The following PRs were merged Add support for npm package #184 #183 #180 #179 #178 #177 #176
Parsed Size | Gzipped Size | Analyze | |
---|---|---|---|
Before | 393.13 KB | 112.75 KB | https://cloudup.com/cvjPjefHXYj |
After | 397.3 KB | 113.91 KB | https://cloudup.com/ck-vWZqQPyR |
Difference | 4.17 KB | 1.16 KB |
As of June 26th, this is the size report:
https://github.com/Automattic/happychat-client/pull/243 has reduced bundle size in 70k parsed and 20K gzipped:
By updating to React 16 in https://github.com/Automattic/happychat-client/pull/249 we've reduced happychat.js size in 36K parsed (448K to 412K), and 11K gzipped (127K to 116K):
Current build size
Run
npm run build:standalone
and note down the sizes of these files intargets/standalone
(note that the bundle analyzer reports a bit more). Thengzip -c file > file.gz
to get the gzipped size.Current bundle distribution (
npm run analyze-bundles
):These are the top-5 components by size:
render
the component tree & tofindDomNode
in some component. Can't be replaced for the managed library, but it wouldn't be necessary for a React/Redux env target (it could be externalized in that case).src/ui
: 67K parsed / 12K gziplodash
: 36K parsed, 10K gzip.src/state
: 31K parsed, 6K gzip.engine.io-client
: 23K parsed, 8K gzip.Some ideas to explore
Resources:
CSS
JS
lodash-webpack-plugin
to drop extras (see). This was done in #174 and reverted in #182 We ran into too many bugs.