🐛 The bug
When using useScript() with warmupStrategy: false, Nuxt Scripts still adds a <link rel="preload"> tag for the script.
In the reproduction, lodash is loaded only as an example script:
useScript(
{
src: 'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js',
},
{
warmupStrategy: false,
}
)
Even though warmupStrategy is explicitly set to false, the page still contains a preload link for lodash.
The reproduction checks this with XPath and shows:
This seems inconsistent with the documented/type behavior where false should disable preloading.
I think the issue may be caused by this runtime check:
if (!options.warmupStrategy) {
options.warmupStrategy = "preload";
}
Since false is a valid value for warmupStrategy, this condition treats false the same as an unset value and overrides it with "preload".
It probably should only apply the default when warmupStrategy is undefined.
🛠️ To reproduce
https://stackblitz.com/edit/nuxt-starter-duaxa3qz?file=pages%2Findex.vue
🌈 Expected behavior
When warmupStrategy: false is passed to useScript(), Nuxt Scripts should not add a <link rel="preload"> tag for that script.
Expected result in the reproduction:
ℹ️ Additional context
No response
🐛 The bug
When using
useScript()withwarmupStrategy: false, Nuxt Scripts still adds a<link rel="preload">tag for the script.In the reproduction, lodash is loaded only as an example script:
Even though
warmupStrategyis explicitly set tofalse, the page still contains a preload link for lodash.The reproduction checks this with XPath and shows:
This seems inconsistent with the documented/type behavior where
falseshould disable preloading.I think the issue may be caused by this runtime check:
Since
falseis a valid value forwarmupStrategy, this condition treatsfalsethe same as an unset value and overrides it with"preload".It probably should only apply the default when
warmupStrategyisundefined.🛠️ To reproduce
https://stackblitz.com/edit/nuxt-starter-duaxa3qz?file=pages%2Findex.vue
🌈 Expected behavior
When
warmupStrategy: falseis passed touseScript(), Nuxt Scripts should not add a<link rel="preload">tag for that script.Expected result in the reproduction:
ℹ️ Additional context
No response