You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
minor #1967 [LazyImage] Webperfs and LCP considerations (Kocal)
This PR was merged into the 2.x branch.
Discussion
----------
[LazyImage] Webperfs and LCP considerations
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no <!-- please update src/**/CHANGELOG.md files -->
| Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License | MIT
<!--
Replace this notice by a description of your feature/bugfix.
This will help reviewers and should be a good start for the documentation.
Additionally (see https://symfony.com/releases):
- Always add tests and ensure they pass.
- For new features, provide some code snippets to help understand usage.
- Features and deprecations must be submitted against branch main.
- Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
- Never break backward compatibility (see https://symfony.com/bc).
-->
Added some documentation to the LazyImage component, about LCP and webperfs considerations.
tl;dr: using the LazyImage _in its initial way_ on the LCP image, will decrease your LCP, lower the user experience, and lower the ranking of your website on Google.
Using the `style="background-image: url(...)"` trick solves this issue, since it allows the browser to download and render the HD image the fastest as possible, while showing the blurhash during the loading.
This is something I've implemented ~1 month ago on our website wamiz.com, and did some comparaison:
- Before, with the LazyImage Stimulus Controller solution, the blured image is not shown at all, and the LCP image discovered too much late: 
- After, with the `style="background-image: url(...)"` trick, we can see the blured image and the LCP image discovered faster: 
Commits
-------
a46b1d3 [LazyImage] Webperfs and LCP considerations
.. _`The progressive loading (through blurhash) is not taken into account in the LCP calculation`: https://github.com/w3c/largest-contentful-paint/issues/71_
259
+
.. _`didn't preload the image`: https://symfony.com/doc/current/web_link.html
0 commit comments