useMenuTrigger adds a lot to bundle size #2999
-
Hello everyone, I was implementing a simple dropdown menu using Still, I think it's quite an overkill for my use case, so I stopped using useMenuTrigger and implemented my own And I was thinking: do I violate something by doing that, or is it okay if I know that the majority of my audience will be English and I'm not planning in the near future to go international? Thank you for this fantastic set of libraries 💖 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I've got a new follow-up for the discussion here. I managed to code-split my Menu component so that it can be loaded after the user interacts with the trigger button. However, the code-splitted chunk is still massive (30kb gzipped), and I found out that a large portion of that size are i18n related modules that I'm not sure if I need at all. For example: Tree shaking should work properly in the project. I also tested it on an empty Next.js project with the example Menu from docs, and the result is the same. Below is a treemap of source maps of the code-splitted chunk, containing only Menu with Section and Items. My question is whether the i18n is really for some usage here (from developer tools coverage, it seems that more than half of this code is not executed at all)? If so, what are they for? Otherwise, is there a way to remove them from the bundle/chunk? |
Beta Was this translation helpful? Give feedback.
-
A few things we can improve here:
If you'd be interested in helping out with improving any of these, that would be awesome. Happy to help guide you. Otherwise, we'll get to them at some point in the future. |
Beta Was this translation helpful? Give feedback.
A few things we can improve here:
useMenuTrigger
includes translations for a string used as an accessibility description. I think it would be nice if (a) you could choose which languages you wish to support rather than always including all 30+, and (b) you could opt out of this string completely if you don't use long press support. I'm not sure exactly how to solve this without overcomplicating the API though. If you have ideas, please let us know!