Skip to content
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

How to improve lighthouse cumulative layout shift score with this package? #36

Open
dosstx opened this issue Dec 21, 2021 · 1 comment

Comments

@dosstx
Copy link

dosstx commented Dec 21, 2021

Hi, loving this plugin.

However, I'm a newbie to responsive images in general and I'm having some trouble understanding how I can improve the lighthouse score for the Performance/Cumulative Layout Shift (CLS) section.

With the following code, I get a lighthouse score of 84 due to CLS:

      <InnerImageZoom
        v-if="post.public_id"
        :src="`https://res.cloudinary.com/${$config.cloudinary.cloudName}/f_auto,q_60,w_900/${post.public_id}`"
        :zoom-src="`https://res.cloudinary.com/${$config.cloudinary.cloudName}/c_scale,w_2000,q_auto:best,f_auto/${post.public_id}`"
        :width="post.width" <---- original width of image is: 3096
       :height="post.height" <---- original height of image is: 2591
        :has-spacer="true"
        :alt="post.title"
        :hide-hint="true"
        :src-set="'https://res.cloudinary.com/XXXX/image/upload/f_auto,q_60,w_510/v1640005494/users/ezcOtHHWVrYLZoPvVOCumfubSUa2/uploads/XXXX.jpg 510w,https://res.cloudinary.com/XXXX/image/upload/f_auto,q_60,w_607/v1640005494/users/ezcOtHHWVrYLZoPvVOCumfubSUa2/uploads/XXXX.jpg 607w,https://res.cloudinary.com/XXXX/image/upload/f_auto,q_60,w_689/v1640005494/users/ezcOtHHWVrYLZoPvVOCumfubSUa2/uploads/XXXX.jpg 689w,https://res.cloudinary.com/XXXX/image/upload/f_auto,q_60,w_769/v1640005494/users/ezcOtHHWVrYLZoPvVOCumfubSUa2/uploads/XXXX.jpg 769w,https://res.cloudinary.com/XXXX/image/upload/f_auto,q_60,w_841/v1640005494/users/ezcOtHHWVrYLZoPvVOCumfubSUa2/uploads/XXXX.jpg 841w,https://res.cloudinary.com/XXXX/image/upload/f_auto,q_60,w_900/v1640005494/users/ezcOtHHWVrYLZoPvVOCumfubSUa2/uploads/XXXX.jpg 900w'"
      />

Whereas, with the following code like so, I get a score of 100:

      <img
       class="img-fluid"
        :src="`https://res.cloudinary.com/${$config.cloudinary.cloudName}/f_auto,q_60,w_900/${post.public_id}`"
        :src-set="'https://res.cloudinary.com/XXXX/image/upload/f_auto,q_60,w_510/v1640005494/users/ezcOtHHWVrYLZoPvVOCumfubSUa2/uploads/XXXX.jpg 510w,https://res.cloudinary.com/XXXX/image/upload/f_auto,q_60,w_607/v1640005494/users/ezcOtHHWVrYLZoPvVOCumfubSUa2/uploads/XXXX.jpg 607w,https://res.cloudinary.com/XXXX/image/upload/f_auto,q_60,w_689/v1640005494/users/ezcOtHHWVrYLZoPvVOCumfubSUa2/uploads/XXXX.jpg 689w,https://res.cloudinary.com/XXXX/image/upload/f_auto,q_60,w_769/v1640005494/users/ezcOtHHWVrYLZoPvVOCumfubSUa2/uploads/XXXX.jpg 769w,https://res.cloudinary.com/XXXX/image/upload/f_auto,q_60,w_841/v1640005494/users/ezcOtHHWVrYLZoPvVOCumfubSUa2/uploads/XXXX.jpg 841w,https://res.cloudinary.com/XXXX/image/upload/f_auto,q_60,w_900/v1640005494/users/ezcOtHHWVrYLZoPvVOCumfubSUa2/uploads/XXXX.jpg 900w'"
        :width="post.width"
        :height="post.height"
        alt="testimage"
      />

Does anyone have any tips on how I can improve the CLS score when using the vue inner image zoom library in Vue2 (I am actually using NuxtJS, but that should be the same)?

Thanks!

@laurenashpole
Copy link
Owner

When you set width, height, and hasSpacer, it should insert a wrapper around your image with padding-bottom set to save the space that your image will load into. If you inspect the original image are you seeing that div? If not I'll have to look into whether using it in combination with Nuxt is causing unexpected issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants