Title: lazysizes
Author: Patrick Sletvold
Published: <strong>2 novembre 2017</strong>
Last modified: 13 août 2020

---

Recherche d’extensions

Cette extension **n’a pas été testée avec plus de trois mises à jour majeures de
WordPress**. Elle peut ne plus être maintenue ou supportée et peut avoir des problèmes
de compatibilité lorsqu’elle est utilisée avec des versions de WordPress plus récentes.

![](https://ps.w.org/lazysizes/assets/icon.svg?rev=2357198)

# lazysizes

 Par [Patrick Sletvold](https://profiles.wordpress.org/16patsle/)

[Télécharger](https://downloads.wordpress.org/plugin/lazysizes.1.3.3.zip)

 * [Détails](https://fr.wordpress.org/plugins/lazysizes/#description)
 * [Avis](https://fr.wordpress.org/plugins/lazysizes/#reviews)
 * [Développement](https://fr.wordpress.org/plugins/lazysizes/#developers)

 [Support](https://wordpress.org/support/plugin/lazysizes/)

## Description

**lazysizes** is a WordPress plugin for the high performance, SEO-friendly and auto-
triggering lazyloader [with the same name](https://github.com/aFarkas/lazysizes).
Support includes images (including responsive images with `srcset` and the `picture`
tag), iframes, scripts/widgets and much more. It also prioritizes resources by differentiating
between crucial in view and near view elements to make perceived performance even
faster. Additionally, you can add low-res/blurry placeholder images using the Blurhash
algorithm.

This plugin works by loading the lazysizes script and replacing the `src` and `srcset`
attributes with `data-src` and `data-srcset` on the front end of a WordPress site.
When a post or page is loaded, the lazysizes javascript will load the images, iframes
etc. dynamically when needed. All you need to do is to enable the plugin, and possibly
tweak a few settings to your liking.

Thanks to aFarkas and contributors for making the [lazysizes library](https://github.com/aFarkas/lazysizes)
possible, and for letting me use the same name.

Also thanks to dbhynds who made the Lazy Load XT plugin, which this plugin is based
on.

## FAQ

### Why aren’t my images lazy loading?

Lazysizes filters images added to the page using `the_content`, `post_thumbnail_html`,`
widget_text` and `get_avatar`. If your images are added using another function (`
wp_get_attachment_image` for example), lazysizes does not filter them by default.
There are several options for changing what lazysizes filters, like enabling it 
to filter `acf_the_content` for WYSIWYG content from Advanced Custom Fields, and
enabling `wp_get_attachment_image` support (somewhat limited, see below). For unsupported
use cases you can also filter the HTML yourself by passing it to `get_lazysizes_html`.

While this plugin has opt-in support for `wp_get_attachment_image`, it doesn’t add
a no-Javascript fallback, which causes images to become invisible for users where
Javascript is disabled or unsupported. We cannot fix this for you automatically,
but you can fix this with a couple of changes to the code that uses `wp_get_attachment_image`.
For example, if a theme has: `echo wp_get_attachment_image($id);`, changing it to
the following would lazy load the image and add no-Javascript fallback if enabled
in settings: `echo get_lazysizes_html( wp_get_attachment_image($id) );`

If a popular plugin is incompatible and has a filter for modifying the HTML output,
lazysizes could most likely get support for that plugin. In that case, feel free
to ask! If the plugin has no such way to filter the output, they would have to add
one for lazysizes to leverage.

### What is the Blurhash placeholder feature, and how do I use it?

The low-res Blurhash placeholder feature generates a text string for each image 
using the [Blurhash](https://blurha.sh/) algorithm. This string includes all the
information necessary for the Blurhash script running in the visitor’s browser to
decode it into a blurry image, which will be shown while the real image is loading.

Because the final image placeholder is generated in JavaScript, users on faster 
internet connections can sometimes see the full image directly for images that are
above the fold. Images lower down on the page will have a placeholder ready by the
time the user reaches them.

The placeholder Blurhash string is not computed on page load, as it can in some 
cases take several seconds to do so. Instead, it will need to be pregenerated. As
long as Blurhash is enabled in the settings, all new images uploaded will have a
Blurhash string generated automatically. Additionally, you can manage the Blurhash
string for each attachment individually in the Media Library. There is an option
to generate and store Blurhash strings on page load, which can be used to easily
generate Blurhash strings for lots of images by visiting the page they’re shown 
on. Just remember to turn that option back off, or your visitors may be slightly
upset.

For technical reasons, Blurhash is only supported for local image attachments, and
at the moment is not officially supported for picture elements. Images without a
Blurhash string will behave just like they do with the option turned off. Blurhash
placeholders work with the existing effects, like fade-in, but in some cases the
perfect fade-in effect may not be possible. The Blurhash placeholder will still 
fade in, but it might not fade when transitioning to the full image. This is because
of a few edge cases not supported by the advanced Blurhash reveal effect.

The advanced Blurhash reveal effect works by creating an additional image element
positioned under the regular image. This gives the best result in combination with
the fade effect, but might not support all WordPress themes. Safeguards exist to
prevent using the advanced effect when not supported (by falling back to the slightly
imperfect fade effect), but in some cases problems may still occur. If you see this
type of problem, you can disable the advanced Blurhash reveal effect in the settings.
Feel free to contact me on the support forums, and I may be able to work out what
was going wrong.

### There’s a plugin called Lazy Load XT. Why does this one look a bit similar?

The PHP code for this plugin was originally based on that of Lazy Load XT, with 
many changes since. The main difference is that this plugin is using a completely
different lazy loading library (lazysizes), with no jQuery dependency. Additionally,
this plugin is actively maintained and has advanced features like Blurhash support.

Thanks to dbhynds for making the Lazy Load XT plugin. Without that project, this
one would not be possible.

### Why is this plugin called lazysizes, the same as the JS library it uses?

There are a few reasons:

 1. I like the name name.
 2. It is a fitting name, as it makes you think of lazy loading.
 3. I’m hoping it will help people discover the plugin. I originally tried searching
    for a WordPress plugin using the library myself, and other people might be trying
    the same.

This plugin is not affiliated with the lazysizes project, but I asked for, and got,
permission by aFarkas to use the name. That’s as far as any connection between the
two go.

## Avis

![](https://secure.gravatar.com/avatar/0a95199eea4addd897a719da81798f915eb1a679d8ebc25582c230e43b1c4d0e?
s=60&d=retro&r=g)

### 󠀁[Best lazy load images WordPress plugin and excellent support!!](https://wordpress.org/support/topic/best-lazy-load-images-wordpress-plugin-and-excelllent-support/)󠁿

 [snippet24](https://profiles.wordpress.org/snippet24/) 27 mai 2020 1 réponse

If you are looking for a Lazysizes wordpress plugin can’t recommend it enough. Also
it has great support from the plugin author.

![](https://secure.gravatar.com/avatar/e4ddac9e8bf0a4c055adaa6264a4e399957798a6b0e19acc13891bee5217e7d5?
s=60&d=retro&r=g)

### 󠀁[Works really great, I love it!!!](https://wordpress.org/support/topic/seems-to-not-work-in-safari-firefox-and-maybe-more-browsers/)󠁿

 [dutze](https://profiles.wordpress.org/dutze/) 30 avril 2019 2 réponses

Works great, even with picture tags! The fade-in effect of the lazyloaded images
is really nice! And the developer is really active and helped me a lot! Thanks again,
Patrick 🙂

![](https://secure.gravatar.com/avatar/675fec7d92d6105a0fcc143d1c56da363c63a87046e5db186834a7c6855fae5f?
s=60&d=retro&r=g)

### 󠀁[Perfect](https://wordpress.org/support/topic/impec-4/)󠁿

 [stephanetessieralu](https://profiles.wordpress.org/stephanetessieralu/) 22 décembre
2018 1 réponse

As a developer I knew the lib js that does a very good job. So I’m not surprised
to have a plugin that does a good job too. (Except, video loading does not work)

![](https://secure.gravatar.com/avatar/629892e11335f5e9824c4063c1549127f310faed615a58fe23c7400ce3998db7?
s=60&d=retro&r=g)

### 󠀁[It’s perfect!!](https://wordpress.org/support/topic/its-perfect-47/)󠁿

 [moji_vb](https://profiles.wordpress.org/moji_vb/) 1 novembre 2018 1 réponse

I already tested some other plugins against this plugin for my site load speed and
request counts. This plugin is greatly reducing my page load speed I really don’t
know why they couldn’t beat this plugins performance on gtmetrix. Performance is
really high as author mentioned!

![](https://secure.gravatar.com/avatar/cc722af407c56aa9608185922eb9fc92e654e2513563c6248cf9a359dd509302?
s=60&d=retro&r=g)

### 󠀁[Best Lazyload script on the planet](https://wordpress.org/support/topic/best-lazyload-script-on-the-planet/)󠁿

 [Arno Kools](https://profiles.wordpress.org/arno-kools/) 3 septembre 2018 1 réponse

LazySizes is lazyloading done right. I’ve used it before and was pleased to see 
that it’s now available as a WordPress plugin. For me, this is the best lazy-load
script on the planet. I’ve tried many Wordpress plugins and all failed except LazySlides.
Excellent!

![](https://secure.gravatar.com/avatar/0e44e8c44b5f1f73193ef4879ca696c2e4c8bd7d0f22080c32244453300777f4?
s=60&d=retro&r=g)

### 󠀁[Excelent!!](https://wordpress.org/support/topic/excelent-561/)󠁿

 [Laura530](https://profiles.wordpress.org/laura530/) 8 mars 2018 1 réponse

Thank you. It is perfect.

 [ Lire les 6 avis ](https://wordpress.org/support/plugin/lazysizes/reviews/)

## Contributeurs/contributrices & développeurs/développeuses

« lazysizes » est un logiciel libre. Les personnes suivantes ont contribué à cette
extension.

Contributeurs

 *   [ Patrick Sletvold ](https://profiles.wordpress.org/16patsle/)

“lazysizes” a été traduit dans 2 locales. Remerciez [l’équipe de traduction](https://translate.wordpress.org/projects/wp-plugins/lazysizes/contributors)
pour ses contributions.

[Traduisez « lazysizes » dans votre langue.](https://translate.wordpress.org/projects/wp-plugins/lazysizes)

### Le développement vous intéresse ?

[Parcourir le code](https://plugins.trac.wordpress.org/browser/lazysizes/), consulter
le [SVN dépôt](https://plugins.svn.wordpress.org/lazysizes/), ou s’inscrire au [journal de développement](https://plugins.trac.wordpress.org/log/lazysizes/)
par [RSS](https://plugins.trac.wordpress.org/log/lazysizes/?limit=100&mode=stop_on_copy&format=rss).

## Journal des modifications

### 1.3.3

 * Add support for WordPress 5.5 and native lazy loading (see point below).
 * Add option for full native lazyloading, which gives the browser full control 
   over when to load the image. Not compatible with the old native lazy load option,
   which only gives the browser partial control over loading. Currently only supports
   images, other elements will be lazyloaded like previously.
 * Add support for transforming HTML using single quotes instead of double quotes
   for attributes.
 * Fix lazy loading for commenter avatars. This feature had actually been disabled
   for a while, because it was broken. The new support for single quote attributes
   fixes this.
 * Fix positioning of the blurhash placeholder when the image is directly inside
   a link element.
 * Fix Blurhash integration in the Media Library being incompatible with certain
   other plugins extending this area using JS. This mainly fixes compatibility with
   the plugin Smush, but should make other plugins more likely to work as well.
 * Fix incompatibilities with certain older versions of WordPress. Please note that
   it is always recommended to use the latest version of WordPress, and that the
   next major version of this plugin will require a more up to date WordPress installation
   than it does now.

### 1.3.2

A partial deploy caused by human error led to a fatal error due to missing files
for versions v.1.3.0 and v1.3.1. This has been fixed, along with the following:

 * Fix warning caused by missing check for metadata existing.
 * Fix script for the attachment page being minified even when SCRIPT_DEBUG is true.
 * Properly implement Blurhash management support in the post editor.
 * Fix non-existent CSS stylesheet being enqueued when no lazy load effect was selected.
 * Improve logic for finding attachment id from an image url.
 * Fix issue with minified lazysizes script.

### 1.3.0

Note that this is the last release that will support PHP 5.6 and WordPress 3.9. 
The next release will most likely require PHP 7.2 and WordPress 4.5 or newer.

 * Add support for generating low-res placeholder images using [Blurhash](https://blurha.sh/),
   which stores the placeholder as a short text string. Computing this string does
   not happen on page load, as it’s rather expensive, but when the blurhash placeholder
   option is enabled it can be controlled individually for each attachment, and 
   new attachments will have a placeholder generated automatically. For more information,
   see the FAQ and the settings page.
 * Add custom lazysizes script and styles feature, which uses scripts and styles
   optimized for size and fewer requests.
 * Improve aspectratio calculation. Local images no longer need both width and height
   set, only one of them, since the aspect ratio can be calculated based on attachment
   metadata.
 * Various performance tweaks.
 * Add experimental option for skipping adding a src attribute to images, and letting
   the browser load the image progressively instead.
 * Fix issue where a picture element with an excluded class could still be lazy 
   loaded.
 * Upgrade lazysizes library to 5.2.2.

### 1.2.1

 * Improve logic for skipping transforming images inside noscript tags. Should fix
   compatibility issues with Envira Gallery’s noscript fallback. Thanks to snippet24
   for reporting.
 * Fix default options not being selected. If you were affected by this bug, see
   a list of [recommended default options here](https://wordpress.org/support/topic/recommended-starting-settings-perhaps/#post-12886169).
   Thanks to snippet24 for reporting.

### 1.2.0

 * Upgrade lazysizes library to version 5.2.0.
 * Add opt-in support for Advanced Custom Fields.
 * The plugin now uses namespaces for PHP classes.
 * Confirmed working with WordPress 5.3 and PHP 7.4.

### 1.1.0

 * Upgrade lazysizes library to version 5.0.0.
 * Add experimental support for native lazy loading.
 * Fix fatal error during ajax processing. Thanks to @eastgate for reporting.
 * Fix PHP warning on certain pages, like the events page from the plugin The Events
   Calendar. Thanks @julian_wave for reporting.

### 1.0.0

Big thanks to martychc23 and dutze for their help and patience in making this release
as good as it is.

 * Proper support for the picture tag, by popular request. Big refactoring of the
   HTML transforming code was done to make picture element support possible.
 * Improve and fix support for audio/video elements. The plugin now handles the 
   preload attribute and leaves the src attribute alone on source elements inside
   video/audio.
 * Opt-in support for get_attachment_image. Please note that the plugin cannot add
   a no-js fallback for images lazy-loaded using this method.
 * Add option to enable/disable noscript fallback
 * Fix plugin action links
 * Several fixes to improve compatibility

### 0.3.0

 * Add support for the aspectratio plugin for lazysizes, which makes images have
   the right height while loading. Thanks to Teemu Suoranta (@teemusuoranta) for
   implementing.
 * If Javascript is turned off, the image tag that would normally be lazy loaded
   is now hidden properly. Thanks to @diegocanal for reporting and fixing.

### 0.2.0

 * Update the lazysizes library to version 4.1.5
 * Fix lazy loading of elements without a class attribute, like some iframes
 * Fix translation loading

### 0.1.3

 * Remove unused code for advanced settings

### 0.1.2

 * Fix text domain loading

### 0.1.1

 * Updated readme

### 0.1.0

 * Initial version of the plugin

## Méta

 *  Version **1.3.3**
 *  Dernière mise à jour **il y a 6 ans**
 *  Installations actives **700+**
 *  Version de WordPress ** 3.9 ou plus **
 *  Testé jusqu’à **5.5.18**
 *  Version de PHP ** 5.6 ou plus **
 *  Langues
 * [English (US)](https://wordpress.org/plugins/lazysizes/), [Italian](https://it.wordpress.org/plugins/lazysizes/),
   et [Norwegian (Bokmål)](https://nb.wordpress.org/plugins/lazysizes/).
 *  [Traduisez la dans votre langue](https://translate.wordpress.org/projects/wp-plugins/lazysizes)
 * Étiquettes
 * [image](https://fr.wordpress.org/plugins/tags/image/)[lazy load](https://fr.wordpress.org/plugins/tags/lazy-load/)
   [lazysizes](https://fr.wordpress.org/plugins/tags/lazysizes/)[performance](https://fr.wordpress.org/plugins/tags/performance/)
 *  [Vue avancée](https://fr.wordpress.org/plugins/lazysizes/advanced/)

## Évaluations

 5 sur 5 étoiles.

 *  [  6 avis à 5 étoiles     ](https://wordpress.org/support/plugin/lazysizes/reviews/?filter=5)
 *  [  0 avis à 4 étoile     ](https://wordpress.org/support/plugin/lazysizes/reviews/?filter=4)
 *  [  0 avis à 3 étoile     ](https://wordpress.org/support/plugin/lazysizes/reviews/?filter=3)
 *  [  0 avis à 2 étoile     ](https://wordpress.org/support/plugin/lazysizes/reviews/?filter=2)
 *  [  0 avis à 1 étoile     ](https://wordpress.org/support/plugin/lazysizes/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/lazysizes/reviews/#new-post)

[Voir tous les avis](https://wordpress.org/support/plugin/lazysizes/reviews/)

## Contributeurs

 *   [ Patrick Sletvold ](https://profiles.wordpress.org/16patsle/)

## Support

Quelque chose à dire ? Besoin d’aide ?

 [Voir le forum de support](https://wordpress.org/support/plugin/lazysizes/)