Native Lazyload

Опис

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.

“Нативний” означає “Швидкий”

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”.

Last but not least, a neat thing to keep in mind is that this plugin will essentially improve itself over time, as more browsers roll out support for the loading attribute.

Використання

Just activate the plugin, and all your images and iframes in post content will be loaded lazily.

Подяки

This plugin is partly based on logic from WP Rig as well as recommendations from web.dev and developers.google.com.

Встановлення

  1. Upload the entire native-lazyload folder to the /wp-content/plugins/ directory or download it through the WordPress backend.
  2. Activate the plugin through the ‘Plugins’ menu in WordPress.

Часті питання

Де знаходяться налаштування плагіну?

Цей плагін не має екрану налаштувань. Просто активувавши його, плагін буде працювати.

How can I prevent an image or iframe from being loaded lazily?

You can add a class skip-lazy to indicate to the plugin you would like to skip lazy-loading for this image or iframe.

This plugin still loads an extra JavaScript file! I don’t want that.

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 the loading attribute and not provide any fallback, you can easily disable it by adding a line add_filter( 'native_lazyload_fallback_script_enabled', '__return_false' ) somewhere in your site’s codebase.

Це працює з AMP?

If you use AMP, you don’t actually need this, since AMP intelligently lazy-loads media out of the box. Still, the plugin is built in a way that it will not break AMP compatibility, just to make sure.

Where should I submit my support request?

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.

How can I contribute to the plugin?

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.

You can also contribute to the plugin by translating it. Simply visit translate.wordpress.org to get started.

Відгуки

02.10.2019
Images do not load properly if you're using a browser other than Chrome. Reported the issue to support and have yet to receive any resolution or hint that they're working on it.
02.10.2019
I can't believe this actually comes from Google. It doesn't work. I installed it and it makes any pictures in the body of any post disappear, showing only the captions, not the actual photos. I am using a high speed connection, I have tested it in both Chrome and Edge. This clearly is not ready to be released. If it "speeds up" your site, it does so by just not showing your photos at all. I'm very disappointed.
Прочитати всі 20 відгуків

Учасники та розробники

“Native Lazyload” — проект з відкритим вихідним кодом. В розвиток плагіну внесли свій вклад наступні учасники:

Учасники

“Native Lazyload” було перекладено на 15 локалізацій. Дякуємо перекладачам за їх роботу.

Перекладіть “Native Lazyload” на вашу мову.

Цікавитесь розробкою?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Журнал змін

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

  • Перша версія