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

Remove query-string dependency (28% smaller bundle size) #605

Conversation

christianvuerings
Copy link
Contributor

@christianvuerings christianvuerings commented Aug 11, 2024

Description

Remove query-string dependency from calendar-link

Goal

Limit the number of dependencies to:

  • improve maintainability
  • reduce bundle size

File size

Approximately 28% smaller:

Before

      6.54 kB: index.modern.mjs.gz
      5.92 kB: index.modern.mjs.br
      6.55 kB: index.umd.js.gz
      5.94 kB: index.umd.js.br

After

      4.70 kB: index.modern.mjs.gz
      4.23 kB: index.modern.mjs.br
      4.70 kB: index.umd.js.gz
      4.25 kB: index.umd.js.br

Notes

In order to keep parity with previous behavior, we had to:

  • Sort the keys of the object alphabetically
  • Filter out null and undefined values
  • Replace + with %20 in the URL to specify spaces

Apart from the filtering of null and undefined values, none of these are strictly necessary, they just made the tests pass.

Support for URLSearchParams

Copy link
Owner

@AnandChowdhary AnandChowdhary left a comment

Choose a reason for hiding this comment

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

LGTM!

Maybe it's a good idea to include somewhere in the README:

This package uses URLSearchParams (Node.js >= 10, 97%+ browsers), but if you need to include a polyfill, you can include url-search-params-polyfill first.

PS: Your post on lessons learned from ChatGPT's website (especially extracting data from Next.js router's JSON page props data) was really cool!

@christianvuerings
Copy link
Contributor Author

LGTM!

Maybe it's a good idea to include somewhere in the README:

This package uses URLSearchParams (Node.js >= 10, 97%+ browsers), but if you need to include a polyfill, you can include url-search-params-polyfill first.

Thank you for the quick review. Updated the README

Copy link
Owner

@AnandChowdhary AnandChowdhary left a comment

Choose a reason for hiding this comment

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

Thank you for your hard work!

@AnandChowdhary AnandChowdhary merged commit 7a1e326 into AnandChowdhary:master Aug 12, 2024
3 checks passed
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.

2 participants