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

with loading=lazy, specifying dimensions improves performance #36

Closed
cappert opened this issue Feb 26, 2020 · 1 comment
Closed

with loading=lazy, specifying dimensions improves performance #36

cappert opened this issue Feb 26, 2020 · 1 comment

Comments

@cappert
Copy link
Member

cappert commented Feb 26, 2020

after #34

Got a warning in the Google Chrome console:

[Intervention] An <img> element was lazyloaded with loading=lazy, but had no dimensions specified. Specifying dimensions improves performance. See https://crbug.com/954323

I think it's because if you don't specify the dimension of the images upfront, the browser has to do a layout pass again while scrolling, which kills the performance.
A lot of browser optimizations are about skipping layout and repaints, see https://developers.google.com/web/fundamentals/performance/rendering.

⚠️ if we specify the dimensions we might break the responsiveness, as bootstrap adds

display: block;
max-width: 100%;
height: auto;

to make the images responsive, so if we specify dimensions we will overwrite that.

In closing I'm not even sure we need to lazy load the photos, it's 20kb jpgs.

@guillaumebriday
Copy link
Member

Fixed in #48. Reopen if needed 👍

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