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

Date: Optimize the usage of moment-timezone to save some kilobytes #12356

Merged
merged 1 commit into from
Nov 28, 2018

Conversation

gziolo
Copy link
Member

@gziolo gziolo commented Nov 27, 2018

Description

With the latest update of moment-timezone library there is a huge increase of the timezones data to be bundled by default. This is the consequence of the bug fix added in moment/moment-timezone#697. It turns out that JSON data is now at 925kB in 0.5.23 version: https://unpkg.com/moment-timezone@0.5.23/data/packed/latest.json. This is a big change comparing to the version 0.5.16 which we still bundle in Gutenberg: https://unpkg.com/moment-timezone@0.5.16/data/packed/latest.json - 126kB.

This PR stops including JSON metadata for timezones because we use WordPress specific timezone in here:
https://github.com/WordPress/gutenberg/blob/master/packages/date/src/index.js#L94-L99
It turns out all that data is never consumed in the application and is useless. This opens some nice improvements for the size of the date bundle.

Before

./build/date/index.js 187 KiB 24 [emitted] date

After

./build/date/index.js 13.2 KiB 24 [emitted] date

How has this been tested?

npm test

Check whether scheduling posts still works as expected in Gutenberg.

Types of changes

Refactoring towards lower bundle size.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@gziolo gziolo added [Type] Build Tooling Issues or PRs related to build tooling [Type] Performance Related to performance efforts [Package] Date /packages/date labels Nov 27, 2018
@gziolo gziolo added this to the 4.6 milestone Nov 27, 2018
@gziolo gziolo self-assigned this Nov 27, 2018
@gziolo gziolo mentioned this pull request Nov 27, 2018
4 tasks
@@ -38,9 +38,6 @@
"classnames": "^2.2.5",
"lodash": "^4.17.10",
"memize": "^1.0.5",
"moment": "^2.22.1",
Copy link
Member Author

Choose a reason for hiding this comment

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

Those dependencies are never used...

@gziolo
Copy link
Member Author

gziolo commented Nov 27, 2018

@atimmer, given that WordPress Core bundles moment-timezone version 0.5.23, I'm wondering how much it will influence the bundle size there :)

Copy link
Member

@ntwb ntwb left a comment

Choose a reason for hiding this comment

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

👍

@gziolo gziolo merged commit 4512195 into master Nov 28, 2018
@gziolo gziolo deleted the update/moment-timezone-optimization branch November 28, 2018 09:42
@youknowriad youknowriad modified the milestones: 4.6, 4.7 Nov 29, 2018
@marharyta
Copy link

@gziolo this is great, when are you releasing?

@gziolo
Copy link
Member Author

gziolo commented Dec 12, 2018

It will be included in the upcoming Gutenberg plugin update this or next week (depending on how testing goes). It should be also included in WordPress core in a week or so. Not sure what is the timeline for that, to be honest. This year is safer to say :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Date /packages/date [Type] Build Tooling Issues or PRs related to build tooling [Type] Performance Related to performance efforts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants