Lazy loading makes your site load faster and saves bandwidth.
This plugin replaces all your post images, post thumbnails, gravatar images and content iframes with a placeholder and loads the content as it gets close to enter the browser window when the visitor scrolls the page. Also works with text widgets.
Since it works with iframes, it also covers embedded videoes from YouTube, Vimeo etc.
You can also lazy load other images and iframes in your theme, by using a simple filter.
Compatible with the RICG Responsive Images plugin for responsive images.
Please let me know if you have any issues. Fastest way to get a response is by Twitter: https://twitter.com/bjornjohansen
- Russian (ru_RU) by Elvisrk
- Hebrew (he_IL) by Imri Sagive
- Polish (pl_PL) by Maciej Gryniuk
- Norwegian Bokmål (nb_NO) by Bjørn Johansen
Development happens at GitHub. Pull requests are very welcome.
If you have images output in custom templates or want to lazy load other images in your theme, you may pass the HTML through a filter:
<?php $img_html = '<img src="myimage.jpg" alt="">'; $img_html = apply_filters( 'bj_lazy_load_html', $img_html ); echo $img_html; ?>
Note for developers: The filter has a priority of 10.
No worries. They get the original element in a noscript element. No Lazy Loading for them, though.
- I’m using a CDN. Will this plugin interfere?
Lazy loading works just fine. The images will still load from your CDN.
- How can I verify that the plugin is working?
Check your HTML source or see the magic at work in Web Inspector, FireBug or similar.
One of the fewest lazy load plugins that update continuously. Lightweight and effective!
- Skip classes regex fix
- Amp compatibility (by mustafauysal)
- Update sponsored by Bonnier Tidskrifter
- Fixed issue with srcset not lazy loading (by krispy1298)
- Compatibility with BadgeOS plugin (by rohitmanglik)
- WP’s theme style for submit button. (by odie2)
- Images will now get the lazy-loaded class onload
- Added optional rudimentary LQIP solution
- Added working regex for selecting elements to skip
- Fixed bug when multiple iframes was on the same line of HTML code
- Added Polish language (by Maciej Gryniuk).
- Remove leftover console.log() from debugging — oh, crap … I know 🙁
- We do not touch the feeds
- Fixed issue where some images wouldn’t be loaded on load under certain conditions.
- Small performance improvement
- PHP 5.2 compatibility again
- Fixes issue with missing placeholder
- Internal rewrite. Code cleanup.
- Supports 3rd party filters
- Supports most infinite scroll (or content lazy loading) plugins (all that triggers post-load)
- No more TimThumb
- No more dependant on 3rd party JS, not even jQuery
- Removed custom responsice/hidpi image handling in favour of compatibility with the RICG Responsive Images plugin
- Added translations to Hebrew (he_IL) by Imri Sagive
- Also applies to text widgets (Thanks to Sigurður Guðbrandsson)
- Skips lazy loading of data-URIs
- Works with newlines in the HTML string for the IMG element
- Re-minified the combined js file for better compability with faulty minifiers
- Proper encoding of non-ASCII characters in filenames when using responsive or hiDPI images (thanks @testsiteoop)
- Added meta box to all public post types to exclude BJ Lazy Load for individual posts/pages
- Placeholder image is replaced with a really short data-uri (thanks @jruizcantero)
- Added a proper WordPress filter method for arbitrary HTML filtering with: apply_filters( ‘bj_lazy_load_html’, $html )
- Updated scbFramework to release 58 (no more strict warnings in admin)
- Updated jQuery.sonar to latest version (as of 2013-11-13)
- Added POT file (Go translate!)
- Added translation to Norwegian Bokmål (nb_NO)
- Added translation to Russian (ru_RU) by Elvisrk
- Responsive and HiDPI images works with MultiSite subfolders
- Lazy loading is disabled on Opera Mini
- Removed leftin print_filters_for() function (sry)
- User definable threshold
- Bugfix: Single quotes for the class attribute is now handled (thanks @kReEsTaL)
- Bugfix: Removed strict error notice (thanks syndrael)
- Bugfix: sonar.js wouldn’t load properly when SCRIPT_DEBUG was set to true (thanks @techawakening)
- Combined JS files for faster loading
- Bugfix for when viewport is resized – now triggering scroll event (thanks @kReEsTaL)
- Option to disable BJ Lazy Load for MobilePress
- Iframe lazy loading is now compatible with Gravity Forms’ ajax forms.
- Disable when viewing printable page from WP-Print
- Detects WPTouch Pro as well
- Bugfix: Remove notice of undefined constant when SCRIPT_DEBUG isn’t defined
- Bugfix: The infinite_scroll option wasn’t initialized
- Optionally serving size optimized images for responsive design/adaptive layout
- Optionally serving hiDPI images (retina support)
- Option to disable BJ Lazy Load for WPTouch
- Fixed issue with infinite scroll (must be enabled on options screen)
- Upgraded jQuery.sonar to latest version
- Possible to skip lazy loading of certain images with specified classnames
- Made the placeholder image override an option setting in wp-admin
- Added filter: bj_lazy_load_placeholder_url – override placeholder image (should be an option setting in the future)
- Added the fadeIn effect
- Lowered jQuery version dependency
- New options: More granular control on what content to lazy load
- Complete rewrite
- Replaced JAIL with jQuery.sonar to accomodate for iframe lazy loading
- Added lazy loading for iframes
- The manual filter code now works as it should, lazy loading all images instead of just the first.
- Upgraded JAIL to version 0.9.9, fixing some bugs. Note: data-href is now renamed data-src.
- Replaced an anonymous function call causing error in PHP < 5.3
- The wp_head caller selector was added to the option page
- Also with d.sturm’s fix (thanks)
- Added BJLL::filter() so you can lazy load any images in your theme
- Added the option to load in wp_head() instead (suboptimal, but some themes actually don’t call wp_footer())
- Correctly removed the lazy loader from feeds
- Fixes Unicode-issue with filenames
- Now (more) compliant to the WP coding style guidelines.
- All strings localized
- Translations get loaded
- POT file included (send me your translations)
- Norwegian translation included
- Now using DOMDocument for better HTML parsing. Old regexp parsing as fallback if DOMDocument is not available.
- Added CSS. No longer need for hiding .no-js .lazy
- Added options whether to include JS and CSS or not
- Added options: Timeout, effect, speed, event, offset, ignoreHiddenImages
- Combining the two JS files for faster loading
- Renamed the plugin file from bj-lazyload.php to bj-lazy-load.php to better fit with the plugin name
- Added options panel in admin
- Added option to lazy load post thumbnails
- Skipped the lazy loading in feeds
- Released 2011-12-05
- It works (or at least it does for me)