Skip to content

Commit 376521f

Browse files
Create images.md
1 parent e02080b commit 376521f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

cheatsheets/html/images.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
title: Images
3+
---
4+
5+
6+
## Optimizing image loading
7+
8+
Code snippets and references to read more.
9+
10+
See [The “Blur Up” Technique for Loading Background Images](https://css-tricks.com/the-blur-up-technique-for-loading-background-images/) on CSS tricks
11+
12+
Resources:
13+
14+
- [The Complete Guide to Lazy Loading Images](https://css-tricks.com/the-complete-guide-to-lazy-loading-images/) - using JS to lazy load main and background images
15+
- [A Native Lazy Load for the Web Platform](https://css-tricks.com/a-native-lazy-load-for-the-web-platform/
16+
- [Tips for rolling your own lazy loading](https://css-tricks.com/tips-for-rolling-your-own-lazy-loading/) (2019 article)
17+
18+
Native lazy loading is new and already available in Chrome 76 from 2019 and is supported in Chromium-based and Firefox browsers from 2020. [source](https://web.dev/native-lazy-loading/)
19+
20+
```html
21+
<img src="image.png" loading="lazy" alt="" width="200" height="200">
22+
23+
<iframe src="https://example.com" loading="lazy"></iframe>
24+
```
25+
26+
Here are the supported values for the `loading` attribute:
27+
28+
- `auto`: Default lazy-loading behavior of the browser, which is the same as not including the attribute.
29+
- `lazy`: Defer loading of the resource until it reaches a calculated distance from the viewport.
30+
- `eager`: Load the resource immediately, regardless of where it's located on the page.

0 commit comments

Comments
 (0)