-
Notifications
You must be signed in to change notification settings - Fork 6
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
Implement gzip and brotli compression in production #598
Conversation
Ahhhhh this makes sense now. Brotli, there are strong arguments that you should not use it for small files, but this focuses on on-the-fly compression which we are not doing. So I think it's okay to press on with this approach. If you'd like to pair on the change to the CDN let me know. |
@sjparkinson yes! @i-like-robots changed his mind and would like to get this implemented and see the benefits so 👍to pairing on the CDN update once the |
Re: CDN, Check this out for what it's worth: https://github.com/Financial-Times/ft.com-cdn/pull/573/files |
packages/dotcom-page-kit-cli/src/operations/getWebpackConfig.ts
Outdated
Show resolved
Hide resolved
4123c64
to
38b4f10
Compare
* Prevents source maps being compressed with gzip and brotli
* Default of plugins is minRatio of 0.8 * minRatio is calculated on Compressed Size / Original Size * Approach agreed here: #566 (comment)
38b4f10
to
cf34663
Compare
Introducing gzip and brotli compression for production builds, addressing the file generation portion of #566.
Before this work:
Page Kit was relying on the built-in Fastly on-the-fly compression which favours performance over maximum smallness.
After this work:
gzip
andbrotli
compressed version of all files, as well as the originalbundle.js
.Demo:
Tested this new webpack configuration in the
kitchen-sink
application:Production build files before:
Production build files after (no longer compressing source maps):
Notes / Considerations:
a) a consumer of Page Kit can extend / amend the compression settings
b) a developer can see how the compression is configured.
Debated whether source maps should also be compressed and decided that anything we ship should be compressed. Perhaps there are alternative opinions and we should reduce the number of files but as the source maps are only downloaded if dev tools are open so perhaps not a concern?UPDATE - Discussed with @i-like-robots and agreed that source maps should not be compressed.There is the option to set aUPDATE - Have set both plugins to compress ALL files by setting theminRatio
for the compression algorithm orthreshold
for minimum file size to run through the algorithms but as discussed with @i-like-robots this would lead to more 'surprising' complexity in return for a very slightly quicker build time so have not implemented.minRatio: 1
so that we can guarantee the CDN will find a.br
and.gz
for all.js
and.css
files.Testing:
kitchen-sink
build tests as they currently run against thedevelopment
build. Is this compression worth adding test step up for testing theproduction
build?dotcom-page-kit-cli