Lazy loading for any/other images
Posted: Tue Jan 21, 2025 8:39 am
Lazy Load by WP Rocket
Unveil Lazy Load
jQuery Image Lazy Load WP
One common drawback for these plugins is the lack of flexibility , meaning you won't be able to lazy load absolutely all images, especially if you're using a custom or custom theme.
LazyLoad without using plugin plugin
For those who have at least a little understanding of the WordPress frontend, the best option would be to use ready-made scripts to implement lazy loading, one of the simplest and most popular is vanilla-lazyload.
1. Download the script and throw it into the theme folder
Download the script and throw it into the folder /your_theme/js/
Download script
2. Edit functions
Add the following gambling data malaysia phone number to the functions.php file :
This code includes the lazy loading script and applies it to all images within article content.
In the second point we enabled lazy loading only for images inside the content output from the visual editor, to use lazy loading for other images used in the template, you will have to go through the files of your theme and wherever necessary replace the src attribute with data-src :
There is no point in enabling lazy loading for images on the first screen, as they are loaded immediately anyway.
4. Additional chips
You can delay loading not only images but also other resource-intensive elements:
iframe — most often, videos from third-party servers or maps are loaded through this tag, which slows down loading quite a bit. We use data-src='example.html' to enable lazy loading.
video — tag for displaying video from your hosting.
We use data-src='example.jpeg' to enable lazy loading of video.
background-image is a very common CSS attribute for displaying background images.
We use data-bg='url(example.jpeg)' to enable lazy loading of the block background.
Lazy Loading with WordPress
After the release of WordPress 5.5, native support for lazy loading became available. This means that for images output by standard WordPress functions, the <img loading='lazy'> attribute will be automatically added and if the user's browser supports this attribute, everything will work fine.
Browser compatibility
Starting with version 76, Chrome began using the loading attribute to lazy load images without the need for third-party libraries and plugins.
ONLY ONE MINUS
At the moment, not all browsers support the loading tag , which means you cannot be sure whether lazy loading will work for the user or not.
Speed calculator for your website
Calculating Time and Server Resource Savings When Implementing Lazy Image Loading
Unveil Lazy Load
jQuery Image Lazy Load WP
One common drawback for these plugins is the lack of flexibility , meaning you won't be able to lazy load absolutely all images, especially if you're using a custom or custom theme.
LazyLoad without using plugin plugin
For those who have at least a little understanding of the WordPress frontend, the best option would be to use ready-made scripts to implement lazy loading, one of the simplest and most popular is vanilla-lazyload.
1. Download the script and throw it into the theme folder
Download the script and throw it into the folder /your_theme/js/
Download script
2. Edit functions
Add the following gambling data malaysia phone number to the functions.php file :
This code includes the lazy loading script and applies it to all images within article content.
In the second point we enabled lazy loading only for images inside the content output from the visual editor, to use lazy loading for other images used in the template, you will have to go through the files of your theme and wherever necessary replace the src attribute with data-src :
There is no point in enabling lazy loading for images on the first screen, as they are loaded immediately anyway.
4. Additional chips
You can delay loading not only images but also other resource-intensive elements:
iframe — most often, videos from third-party servers or maps are loaded through this tag, which slows down loading quite a bit. We use data-src='example.html' to enable lazy loading.
video — tag for displaying video from your hosting.
We use data-src='example.jpeg' to enable lazy loading of video.
background-image is a very common CSS attribute for displaying background images.
We use data-bg='url(example.jpeg)' to enable lazy loading of the block background.
Lazy Loading with WordPress
After the release of WordPress 5.5, native support for lazy loading became available. This means that for images output by standard WordPress functions, the <img loading='lazy'> attribute will be automatically added and if the user's browser supports this attribute, everything will work fine.
Browser compatibility
Starting with version 76, Chrome began using the loading attribute to lazy load images without the need for third-party libraries and plugins.
ONLY ONE MINUS
At the moment, not all browsers support the loading tag , which means you cannot be sure whether lazy loading will work for the user or not.
Speed calculator for your website
Calculating Time and Server Resource Savings When Implementing Lazy Image Loading