=== Lazyload, Preload, and More! === Contributors: aryadhiratara, thinkdigitalway Tags: lazyload, lazy load, loading eager, core web vitals, pagespeed, performance, preload, web vitals, image, iframe, video, woocommerce, Requires at least: 5.8 Tested up to: 6.3 Requires PHP: 7.4 Stable tag: 1.0.4 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html A drop dead simple and lightweight image, iframe, and video optimization plugin to satisfy Google PageSpeed Insights and Core Web Vitals. == Description == A drop dead simple and lightweight image, iframe, and video optimization plugin to satisfy Google PageSpeed Insights, Lighthouse, and overall user experience. This tiny little plugin (around **14kb** zipped) will automatically - **lazyload** your below the fold images/iframes/videos, - **preload** your featured images (should also works well with WooCommerce product featured image), - **add loading="eager"** to your featured image and all images that have `no-lazy` or `skip-lazy` class. - **add missing image dimension** to images that doesn't have width and height attribute ## Features - **Lazy Load**: - Images, iframes, and videos. - Inline background images. - CSS background image (simply put `lazyload` class to the background image container) - **Preload Featured Images** Automatically preloading featured image from common page/post (homepage, pages except homepage, single post, and WooCommerce single product pages) - **Add loading="eager" attribute** to to your featured image and all images that have `no-lazy` or `skip-lazy` class. - **Add missing image dimension** to images that doesn't have width and height attribute [since 1.0.3] Should works well with all page builders and theme builders. This plugin also able to lazy loading WooCommerce images and preloading WooCommerce product featured images. ##Disclaimer - Lazy load feature are using **Lazysizes** library (around **3kb**, gzipped and minified). - This plugin doesn't add anything to your database since there's no settings and options. Everything will automatically activated after you activate the plugin. - You can change some default settings using filter. - This plugin is the simplified version of **[Optimize More! – Images](https://wordpress.org/plugins/optimize-more-images/)**, if you don't want to use filters and need to control the settings with UI, you can try that plugin instead of this one. ##About Lazysizes Lazysizes is highly performant lazy load library, written by Alexander Farkas in pure JS with no dependencies. **Taken from lazysize's github description**: *High performance and SEO friendly lazy loader for images (responsive and normal), iframes and more, that detects any visibility changes triggered through user interaction, CSS or JavaScript without configuration.* ##Filters Example filter to add extra lazyload exclude list: add_filter( 'lpam_extra_exclude_list', function($lpam_extra_exclude_list) { return array( 'my-logo', 'my-hero-img', 'exclude-lazy' ); } ); Example filter to change lazysizes config (Read the [docs](https://github.com/aFarkas/lazysizes/#js-api---options)): add_filter( 'lpam_lazysizes_js_before', function($lpam_lazysizes_js_before) { return 'window.lazySizesConfig = { expand: 500, threshold: 500 };' } ); Example filter to change the image sizes for preload featured image: add_filter( 'lpam_preload_featured_images_image_size', function($image_size, $post) { if ( is_singular( 'post' ) ) { return 'large'; } elseif ( is_singular( 'product' ) ) { return 'full'; } else { return $image_size; } }, 10, 2 ); [_new_ since **1.0.2**] Example to disable the preload featured image feature in certain page-type: add_filter('disable_featured_image_preload', function ($disable) { if ( is_singular( 'post' ) ) { return true; } }); [_new_ since **1.0.3**] Example to disable adding image dimension in certain page-type: add_filter('disable_img_dimension', function ($disable) { if ( is_singular( 'post' ) ) { return true; } }); [_new_ since **1.0.3**] Example to disable this plugin completely in certain page using url: add_filter('lazy_load_excluded_pages', function ($excludedPages) { $excludedPages[] = '/page-1'; $excludedPages[] = '/page-2'; return $excludedPages; }); [_new_ since **1.0.3**] Example to disable this plugin completely in certain page using page ID: add_filter('lazy_load_excluded_page_ids', function ($excludedPageIDs) { $excludedPageIDs[] = 3678; // Exclude page with ID 1 $excludedPageIDs[] = 3615; // Exclude page with ID 2 return $excludedPageIDs; }); [_new_ since **1.0.4**] To disable the