1. Go to this page and download the library: Download kunoichi/assets-lazy-loader library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kunoichi / assets-lazy-loader example snippets
// in your functions.php
// Enable image lazy loader.
Kunoichi\AssetsLazyLoader\ImageLazyLoader::enable();
// If you want exclude some image(e.g. Featured image)
// a filter hook is available.
add_filter( 'assets_lazy_loader_image', function( $should, $tag ) {
return false !== strpos( $tag, 'size-post-thumbnail' );
}, 10, 2 );
Kunoichi\AssetsLazyLoader\ScriptsDefer::enable( [
'exclude' => ['jquery-core'], // Only jQuery is not deferred.
'in_login' => true, // Add defer on login screen. Default false.
'in_admin' => true, // Same as above.
] );
Kunoichi\AssetsLazyLoader\ScriptsDefer::enable( [
// Defer scripts only which you know they are safe with defer attribute.
'exclude' => [ 'your-js', 'jquery' ],
] );