N
Nuxtβ€’2y ago
FoxCode

Reduce unused javascript (nuxt)

After nuxt generate about 50% of index.js is not even used on the home page, can it be changed somehow?
No description
20 Replies
Unknown User
Unknown Userβ€’15mo ago
Message Not Public
Sign In & Join Server To View
Filipe Crespo Dev
Filipe Crespo Devβ€’7mo ago
@manniL / TheAlexLichter You have example for this ?
manniL
manniLβ€’7mo ago
Very project specific IMO
Filipe Crespo Dev
Filipe Crespo Devβ€’7mo ago
my project have the same problem i saw the file in my project and the lib (nuxt3-leaflet) is responsible for more than 50% have a option for included a lib only in page necessary?
Rigo
Rigoβ€’7mo ago
There are many options. I can discuss it with you if you feel like, hit me in DM (it depends on your project, on how many plugins you have, on how things get thrown around etc etc.)
manniL
manniLβ€’7mo ago
of course, you can always lazy-load dependencies πŸ™‚ but as Rigo said, it depends a lot on the project
salomon_.
salomon_.β€’7mo ago
Will that affect only bundling? Component still be server side rendered, right?
Filipe Crespo Dev
Filipe Crespo Devβ€’7mo ago
you have a example using lazy-load dependencies
manniL
manniLβ€’7mo ago
it will effect bundling + what JS is loaded when but SSR will still work
Filipe Crespo Dev
Filipe Crespo Devβ€’7mo ago
@manniL / TheAlexLichter @Rigo I'm using SSR with Lazy in the components, but it doesn't work. the site still contains a lot of unused JS.
No description
Filipe Crespo Dev
Filipe Crespo Devβ€’7mo ago
I've seen several configs, in vite, rollup, nitro and nuxt but all note remove the unused js
Rigo
Rigoβ€’7mo ago
Can we see your plugins? How are you loading external libraries?
Filipe Crespo Dev
Filipe Crespo Devβ€’7mo ago
modules: [
'@pinia/nuxt',
'nuxt-icon',
'@nuxt/image',
'@vueuse/nuxt',
'@nuxtjs/critters',
'@nuxtjs/tailwindcss',
'@nuxtjs/google-fonts',
'nuxt-gtag',
'nuxt-simple-robots',
'vue3-carousel-nuxt',
'@nuxtjs/sitemap',
'@nuxt/image',
'nuxt3-leaflet',
],
modules: [
'@pinia/nuxt',
'nuxt-icon',
'@nuxt/image',
'@vueuse/nuxt',
'@nuxtjs/critters',
'@nuxtjs/tailwindcss',
'@nuxtjs/google-fonts',
'nuxt-gtag',
'nuxt-simple-robots',
'vue3-carousel-nuxt',
'@nuxtjs/sitemap',
'@nuxt/image',
'nuxt3-leaflet',
],
Rigo
Rigoβ€’7mo ago
These are modules Do you have any plugins? Are you registering global components somewhere? I think I found the culprit
Rigo
Rigoβ€’7mo ago
GitHub
Nuxt-Leaflet/src/runtime/leaflet-runtime.ts at main Β· Gugustinette/...
A Nuxt 3 module to use Leaflet. Contribute to Gugustinette/Nuxt-Leaflet development by creating an account on GitHub.
Rigo
Rigoβ€’7mo ago
Nuxt leaflet module contains a plugin that load the whole leaflet package Which results as unused code in a page without leaflet map
Rigo
Rigoβ€’7mo ago
leaflet v1.9.4 ❘ Bundlephobia
Find the size of javascript package leaflet v1.9.4. Bundlephobia helps you find the performance impact of npm packages.
Filipe Crespo Dev
Filipe Crespo Devβ€’7mo ago
In this case, what is the best way to import?
Cue
Cueβ€’7mo ago
GitHub
GitHub - vue-leaflet/vue-leaflet: vue-leaflet compatible with vue3
vue-leaflet compatible with vue3. Contribute to vue-leaflet/vue-leaflet development by creating an account on GitHub.
FoxCode
FoxCodeOPβ€’7mo ago
No, I just ignored it, now I wish that my biggest problem was unused javascript πŸ˜…
Want results from more Discord servers?
Add your server