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
Copy file name to clipboardExpand all lines: src/content/docs/images/tutorials/optimize-mobile-viewing.mdx
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,14 +6,12 @@ sidebar:
6
6
order: 1
7
7
---
8
8
9
-
You can use lazy loading to optimize the images on your webpages for mobile viewing. Lazy loading works by deferring the loading of resources, like images, on a page until they are actually needed. This helps address common challenges of mobile viewing, like slow network connections or weak processing capabilities.
9
+
You can use lazy loading to optimize the images on your webpages for mobile viewing. This helps address common challenges of mobile viewing, like slow network connections or weak processing capabilities.
10
10
11
11
Lazy loading has two main advantages:
12
12
***Faster page load times** — Images are loaded as the user scrolls down the page, instead of all at once when the page is opened.
13
13
***Lower costs for image delivery** — When using Cloudflare Images, you only pay to load images that the user actually sees. With lazy loading, images that are not scrolled into view do not count toward your billable Images requests.
14
14
15
-
Without lazy loading, for most browsers, all images are fetched by default, which takes longer. Images are prioritized based on their distance from the viewport, so images in or close to the viewport are loaded first.
16
-
17
15
Lazy loading is natively supported on all Chromium-based browsers like Chrome, Safari, Firefox, Opera, and Edge.
18
16
19
17
:::note
@@ -22,11 +20,13 @@ If you use older methods, involving custom Javascript or a Javascript library, l
22
20
23
21
## Modify your loading attribute
24
22
25
-
There are two possible `loading` attributes for your `<img>` tags: `lazy` and `eager`.
23
+
Without modifying your loading attribute, most browsers will fetch all images on a page, prioritizing the images that are closest to the viewport by default. You can override this by modifying your `loading` attribute.
24
+
25
+
There are two possible `loading` attributes for your `<img>` tags: `lazy` and `eager`.
26
26
27
27
### Lazy loading
28
28
29
-
Lazy loading is recommended for most images.
29
+
Lazy loading is recommended for most images. With Lazy loading, resources like images are deferred until it reaches a certain distance from the viewpoint. If an image doesn't reach the threshold, then it does not get loaded.
30
30
31
31
Example of modifying the `loading` attribute of your `<img>` tags to be `"lazy"`:
32
32
````HTML
@@ -35,7 +35,7 @@ Example of modifying the `loading` attribute of your `<img>` tags to be `"lazy"`
35
35
36
36
### Eager loading
37
37
38
-
If you have images that are in the viewport, eager loading, instead of lazy loading, is recommended.
38
+
If you have images that are in the viewport, eager loading, instead of lazy loading, is recommended. Eager loading loads the asset at the initial page load, regardless of its location on the page.
39
39
40
40
Example of modifying the `loading` attribute of your `<img>` tags to be `"eager"`:
0 commit comments