Quantcast
Channel: Support – Jetpack
Viewing all articles
Browse latest Browse all 371

Lazy Images

$
0
0

Lazy Images makes pages load much faster by only loading visible images, waiting to load images that are offscreen as you scroll down.

In an effort to improve and optimize your site’s loading time, Lazy Images provides a significant benefit in page speed and bandwidth and is especially great for users in low-bandwidth or expensive-bandwidth environments, particularly for mobile users.

Activating Lazy Images

  1. Navigate to Jetpack → Settings → Writing.
  2. Scroll to the Speed up your site section.
  3. Click the toggle to activate Lazy load images.

What does it do?

Lazy images filters the post content and modifies image tags so that the src attribute loads a transparent placeholder image.

So, for example, <img src="https://jetpack.com/image.jpg" /> would become something like <img src="https://jetpack.com/placeholder.jpg" data-lazy-src="https://jetpack.com/image.jpg" /> .

When JavaScript then loads, it will look for all images in the current view and replace the src attribute with what is in data-lazy-src. This also occurs as the user scrolls down the page and images come into view.

Why does this matter?

Lazy images can drastically improve site performance. With mobile usage of the Internet now surpassing that of the desktop, the majority of our users are likely accessing our content with mobile devices. Site performance optimization is incredibly significant.

By default, when a web page loads, it attempts to also load all of the images that it sees in the source. For a visitor using a desktop browser, the time and bandwidth necessary to load that page may not be an issue.

For mobile visitors, where the view is much narrower and bandwidth is a more significant concern, this full loading can be problematic. That’s using bandwidth to load images that they may not even want to see.

With lazy images, those images will only load when they actually appear on-screen, reducing bandwidth usage by as much as half of what is used without lazy images enabled.

Customizing Lazy Images

The code snippets below provide examples of some of the filters included in the module. You can add these code snippets to a functionality plugin or to your theme’s functions.php file.

These filters allow you to tweak the lazy image functionality.

Lazy images is set to be enabled for your entire site by default. You can use the filter is lazyload_is_enabled to customize when lazy loading should be enabled. For example, if you don’t want lazy images to run on a certain page, you could hook in and disable lazy images for that page.

By default, Jetpack will load a 1×1 transparent gif, but certain implementations may call for something else. The filter lazyload_images_placeholder_image will allow you to specify your own placeholder image.

The jetpack_lazy_images_new_attributes filter will allow you to modify the attributes for a lazy loaded image as the content is filtered. This is to allow for changes based on more customized and specific implementations.

Have questions? Please feel free to contact us  for more personalized assistance.


Viewing all articles
Browse latest Browse all 371

Trending Articles