You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First Load JS(using @next/bundle-analyzer to check)
Bundle size without the Select component: 112kB
The bundle size of the Select component: 140kB
I tried using next/dynamic to import SelectContent, but this doesn't work, as long as I import the '@/components/ui/select' file in the component, even if I only import the <Select> component, it will still increase the bundle size by 28kB.
My idea is to only display the content of <SelectTrigger> when the page is first rendered (because the user may not click it at all, so there is no need to load the content of <SelectContent> immediately). When the user clicks the Select component, the content in <SelectContent> is dynamically imported.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
First Load JS(using
@next/bundle-analyzer
to check)I tried using
next/dynamic
to importSelectContent
, but this doesn't work, as long as I import the'@/components/ui/select'
file in the component, even if I only import the<Select>
component, it will still increase the bundle size by 28kB.My idea is to only display the content of
<SelectTrigger>
when the page is first rendered (because the user may not click it at all, so there is no need to load the content of<SelectContent>
immediately). When the user clicks theSelect
component, the content in<SelectContent>
is dynamically imported.How can I optimize this bundle size? Thanks in advance! :-)
Beta Was this translation helpful? Give feedback.
All reactions