-
Notifications
You must be signed in to change notification settings - Fork 32
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
Allow loading BoosterYoutube image non-lazily #1055
Comments
Hello @amplitudesxd, I think this can be solved. Are you working with the https://basics.github.io/nuxt-booster/guide/usage.html#critical-prop-for-critical-components If the component recognizes that it is in a critical component, then the poster is delivered as a preload. This can solve the problem. Call the |
Hey @ThornWalli, Thanks for that information - I've tried adding the critical prop to the BoosterYoutube element, but the loading="lazy" still persists, and lighthouse continues to show that warning. |
@amplitudesxd That should work.
<template>
<div>
<booster-youtube :url="url" />
</div>
</template>
<script setup>
import BoosterYoutube from '#booster/components/BoosterYoutube';
import { useBoosterCritical } from '#imports';
useBoosterCritical();
const url = ref('https://www.youtube.com/watch?v=cLKvbhfVBUU');
</script>
<template>
<div>
<ComponentA critical />
</div>
</template> |
Hi @ThornWalli, thanks for that example - I'm still not quite sure if I'm doing something wrong. My code is as follows, but it still seems to load lazily: <script setup lang="ts">
import BoosterYoutube from '#booster/components/BoosterYoutube';
import { useBoosterCritical } from '#imports';
useBoosterCritical();
</script>
<template>
<div>
<BoosterYoutube
url="https://youtube.com/watch?v=JxS5E-kZc2s"
title="Funny Cats Compilation (Most Popular) Part 1"
critical
/>
</div>
</template> |
Hello @amplitudesxd, you can try the Now it is also possible to set a |
@ThornWalli Thank you! That seems to do the trick. I think would be helpful to add a prop to customize the NuxtImage values, similar to the |
@amplitudesxd I see, what exactly are you missing? https://image.nuxt.com/usage/nuxt-img#modifiers Consider implementing them as a property. In the |
@ThornWalli mainly, I need to be able to set the the |
I've given it some more thought 😉 The plan now is that there is only one property to define the poster sources. {
posterSources: {
type: Array,
default() {
return [
{
src: null,
media: 'all',
sizes: {
default: '100vw'
}
}
];
}
}
} With Preset: {
posterSources: {
type: Array,
default() {
return [
{
src: null,
preset: 'name',
media: 'all',
sizes: {
default: '100vw'
}
}
];
}
}
} With Modifiers {
posterSources: {
type: Array,
default() {
return [
{
src: null,
media: 'all',
modifiers: {
negate: true
},
sizes: {
default: '100vw'
}
}
];
}
}
} With custom src {
posterSources: {
type: Array,
default() {
return [
{
src: '/img/image-text-b.jpg',
media: 'all',
sizes: {
default: '100vw'
}
}
];
}
}
} |
@ThornWalli that looks like an improvement - but from my look at the code, you still wouldn't be able to specify the The overall idea would be that I can render the BoosterYoutube thumbnails with the IPX provider while using Cloudflare for everything else. Something like: <template>
<div>
<BoosterYoutube
url="https://youtube.com/watch?v=JxS5E-kZc2s"
title="Funny Cats Compilation (Most Popular) Part 1"
:imageOptions="{ provider: 'ipx'}"
critical
/>
</div>
</template> Which would then eventually render the I could try to make a PR if that'd help, but I'm quite unfamiliar with this project. |
Hello @amplitudesxd, I already understood that 🙂 Just wanted to add a little more flexibility. The sources that are defined are in theory individual The source in this case is the Your use case: const videoYoutube = {
title: 'Youtube',
url: 'https://www.youtube.com/watch?v=cLKvbhfVBUU',
text: 'Nunc odio nisl dapibus consequat recusandae doloremque nisi natus repudiandae do accusantium corrupti. Harum quisquam, maxime, perspiciatis lobortis earum iure.',
posterSources: [
{
provider: 'ipx',
sizes: {
default: '100vw'
}
}
]
}; Another use case where the image is played out on different orientations: const videoYoutube = {
title: 'Youtube',
url: 'https://www.youtube.com/watch?v=cLKvbhfVBUU',
text: 'Nunc odio nisl dapibus consequat recusandae doloremque nisi natus repudiandae do accusantium corrupti. Harum quisquam, maxime, perspiciatis lobortis earum iure.',
posterSources: [
{
provider: 'ipx',
media: '(orientation: landscape)',
sizes: {
default: '100vw'
}
},
{
provider: 'otherProvider',
media: '(orientation: portrait)',
modifiers: {
ratio: 1
},
sizes: {
default: '100vw'
}
}
]
}; The next step would be to deploy the changes to |
@ThornWalli, ah okay -- that makes sense, I wasn't aware you could specify a provider in sources like that 😊 The changes you've made look great and are a fantastic addition to the project. Thank you for making this! |
@amplitudesxd, you can test the change now |
@ThornWalli seems to be working! Thank you very much :) |
Perfect! 🎉 Will be officially included soon 😉 |
Is your feature request related to a problem? Please describe.
By default, the placeholder image for BoosterYoutube is loaded lazily. This can slow down the LCP if it's in the main viewport.
Describe the solution you'd like
You should be able to decide if the BoosterYoutube image is loaded lazily or not.
Describe alternatives you've considered
N/A - looked through the code, couldn't find any workaround.
Additional context
N/A
The text was updated successfully, but these errors were encountered: