Lazy-Loading to All Images in WordPress 5.4

WordPress announced that WordPress 5.4 may feature image lazy-loading by default. This feature will enable the “loading” HTML attribute on all IMG elements. WordPress publishers will no longer need to use JavaScript or third party plugins for lazy-loading their images.

Lazy-loading

The lazy-loading HTML attribute tells a browser to either wait before downloading an image or to download it right away. There is no JavaScript need to accomplish this.

There are three kinds of lazy-loading attributes but only two that really matter:

  1. Lazy
  2. Eager

Lazy, which will be enabled in WordPress 5.4 by default, means to wait until the users browser viewport is within a certain distance before downloading the image. This behavior will speed up a users experience on WordPress sites.

The “eager” attribute tells the browser to immediately download the image.

WordPress 5.4 Release Date

WordPress 5.4 is currently set to release on March 31, 2020. That date is subject to change depending on how ready the release is. But WordPress has been very good about meeting their deadlines.

According to the WordPress announcement:

“The implementation seeks to enable lazy-loading images by default, providing the loading attribute with value lazy on the following img tags:

Images in post content
Images in post excerpts
Images in comments
Images in text widget content
Individual images rendered via wp_get_attachment_image()
Avatar images rendered via get_avatar()

Note that loading=”lazy” will only be added if the respective tag does not yet include a loading attribute. In other words, to prevent an image from being lazy-loaded, it is recommended to specify loading=”eager”.”

According to the WordPress comments, the lazy-loading attributes will be implemented in a manner that makes it easy to remove them. This is important in case future browsers begin lazy-loading all images by default, without the need for a loading attribute.

Google has indicated via Web.dev that there are plans to automatically enable lazy-loading to all images when a browser in the Lite mode (formerly known as Data Saver mode).

Test Drive WordPress Lazy-Loading

The WordPress team has officially released a WordPress lazy-loading plugin designed for testing purposes. Publishers who want to test it and give feedback are welcome to download the plugin and give it a try.

Rate this post
error: Content is protected !!