Skip to content
WordPress plugin to lazy-load media using the native browser feature.
PHP Shell JavaScript
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Scaffold plugin. Aug 27, 2019
assets-wp-repo Add plugin repository assets. Sep 5, 2019
assets Merge branch 'master' into fix/6 Sep 11, 2019
src Bump version numbers to 1.0.1, and update changelog. Sep 11, 2019
tests/phpunit Merge pull request #9 from GoogleChromeLabs/fix/4 Sep 11, 2019
.babelrc Introduce Webpack, Babel etc, and JS build process. Aug 28, 2019
.editorconfig Scaffold plugin. Aug 27, 2019
.eslintignore Introduce Webpack, Babel etc, and JS build process. Aug 28, 2019
.eslintrc.json Introduce Webpack, Babel etc, and JS build process. Aug 28, 2019
.gitignore Introduce Webpack, Babel etc, and JS build process. Aug 28, 2019
.travis.yml Remove unused integration tests infrastructure. Sep 5, 2019
CONTRIBUTING.md Scaffold plugin. Aug 27, 2019
LICENSE Fix minor license issue. Sep 3, 2019
README.md Add trailing slash to wordpress.org link. Sep 5, 2019
composer.json Bump version numbers to 1.0.1, and update changelog. Sep 11, 2019
deploy.sh Require files manually in case there's no Composer Autoloader, to red… Sep 5, 2019
license.txt Fix license.txt format. Sep 5, 2019
native-lazyload.php Bump version numbers to 1.0.1, and update changelog. Sep 11, 2019
package.json Bump version numbers to 1.0.1, and update changelog. Sep 11, 2019
phpcs.xml.dist Fix outdated WPCS rule. Sep 5, 2019
phpunit.xml.dist Scaffold plugin. Aug 27, 2019
readme.txt Bump version numbers to 1.0.1, and update changelog. Sep 11, 2019
webpack.config.js Fix minor license issue. Sep 3, 2019

README.md

WordPress plugin WordPress Build Status

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.

"Native" means "Fast"

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.

Download

The easiest way to get the plugin is to install it from your WordPress admin dashboard, or manually download it from wordpress.org. Alternatively, you can also clone or download this repository to get the development version, but you will need to run a few commands to process assets and set up the autoloader:

  1. composer install
  2. npm install
  3. npm run build

Requirements

  • WordPress >= 4.7
  • PHP >= 7.0

Contributing

Any kind of contributions to Native Lazyload are welcome. Please read the contributing guidelines to get started.

Credit

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

You can’t perform that action at this time.