Commit e4a5897
committed
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 considerations1 file changed
+40
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
208 | 243 | | |
209 | 244 | | |
210 | 245 | | |
| |||
217 | 252 | | |
218 | 253 | | |
219 | 254 | | |
220 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
0 commit comments