Description
Lazy-loads media using the native browser feature. Learn more about the new loading
attribute or view the WordPress core ticket where inclusion of a similar implementation in WordPress core itself is being discussed.
If the loading
attribute is not supported by the browser, the plugin falls back to a JavaScript solution based on IntersectionObserver
. For the case that JavaScript is disabled, but the loading
attribute is supported by the browser, a noscript
variant of the respective element will be added that also includes the loading
attribute without any further changes.
« Native » signifie « rapide »
If you have found your way over here, you are probably aware of how crucial performance is for a website’s user experience and success. You might also know that lazy-loading is a key feature to improve said performance. However, the solutions for lazy-loading so far still added a bit of overhead themselves, since they relied on loading, parsing and running custom JavaScript logic, that may be more or less heavy on performance.
This plugin largely does away with this pattern. It relies on the new loading
attribute, which makes lazy-loading a native browser functionality. The attribute is already supported by Chrome, and will be rolled out to other browsers over time. The solution being « native » means that it does not rely on custom JavaScript logic, and thus is more lightweight. And « more lightweight » means « faster ».
Enfin, il est important de garder à l’esprit que cette extension s’améliorera avec le temps, à mesure que de plus en plus de navigateurs utiliseront l’attribut loading
.
Utilisation
Activez simplement l’extension et toutes vos images et iframes dans le contenu des publications seront chargées en différé.
Crédit
This plugin is partly based on logic from WP Rig as well as recommendations from web.dev and developers.google.com.
Installation
- Upload the entire
native-lazyload
folder to the/wp-content/plugins/
directory or download it through the WordPress backend. - Activez l’extension via le menu « Extensions » dans WordPress.
FAQ
- Où se trouvent les réglages de l’extension ?
-
Cette extension n’a pas d’écran de réglages. Il suffit de l’activer pour qu’elle fonctionne.
- Comment puis-je empêcher le chargement différé d’une image ou d’une iframe ?
-
You can add a class
skip-lazy
to indicate to the plugin you would like to skip lazy-loading for this image or iframe. - Cette extension charge toujours un fichier JavaScript additionnel ! Je n’en veux pas.
-
This is perfectly fair. Note that the plugin only loads the JavaScript file as a fallback for when the user’s browser does not support the native
loading
attribute yet. The file includes logic to still autoload the image in a non-native way. If you prefer to purely rely on theloading
attribute and not provide any fallback, you can easily disable it by adding a lineadd_filter( 'native_lazyload_fallback_script_enabled', '__return_false' )
somewhere in your site’s codebase. - Cela fonctionne-t-il avec AMP ?
-
Si vous utilisez AMP, vous n’en avez pas vraiment besoin, car AMP charge intelligemment et en différé les médias prêts à l’emploi. Néanmoins, l’extension est construite de manière à ne pas casser la compatibilité AMP, juste pour s’en assurer.
- Où dois-je envoyer ma demande de support ?
-
For regular support requests, please use the wordpress.org support forums. If you have a technical issue with the plugin where you already have more insight on how to fix it, you can also open an issue on Github instead.
- Comment puis-je contribuer à l’extension ?
-
If you have some ideas to improve the plugin or to solve a bug, feel free to raise an issue or submit a pull request in the Github repository for the plugin. Please stick to the contributing guidelines.
Vous pouvez également contribuer à l’extension en la traduisant. Visitez simplement translate.wordpress.org pour commencer.
Avis
Contributeurs/contributrices & développeurs/développeuses
« Native Lazyload » est un logiciel libre. Les personnes suivantes ont contribué à cette extension.
Contributeurs“Native Lazyload” a été traduit dans 16 locales. Remerciez l’équipe de traduction pour ses contributions.
Traduisez « Native Lazyload » dans votre langue.
Le développement vous intéresse ?
Parcourir le code, consulter le SVN dépôt, ou s’inscrire au journal de développement par RSS.
Journal
1.0.2
- Fix broken images which are using data URI scheme (e.g. base64-encoded images). Props ieim.
- Fix images in IE 11 not being loaded until the user starts scrolling. Props Soean.
- Fix image loading script not working in IE10 and other browsers that do not support
dataset
.
1.0.1
- Improve compatibility with other plugins by using more specific class and only adding it for JS fallback.
- Run lazy-load script on
DOMContentLoaded
when necessary to improve compatibility with plugins like Autoptimize. - Do not transform elements inside an AJAX response due to lack of predictability of the context and script execution.
1.0.0
- Version initiale