Kevin Weber
Lazy Load for Videos byThis plugin improves page load time and increases your Google PageSpeed Score. It works with oEmbed and replaces embedded Youtube and Vimeo videos with a clickable preview image. By loading videos only when the user clicks on the preview image, no unnecessary JavaScript is loaded. Especially on sites with many embedded videos this will make your visitors happy. Additionally, all Youtube videos are loaded in a privacy-enhanced mode using the "https://www.youtube-nocookie.com" embed URL.
Download link and more information on the developer's website
How to contribute?
This is open source. Everyone can contribute, including you! I'm looking forward to review and merge your contribution. Here are a few steps to help you get started:
- Fork/clone this repository to your computer.
- Navigate to your downloaded folder in your terminal.
- Install the project-specific npm dependencies (run:
npm install
). - Afterwards you can run
npm run watch
to automatically compile all JavaScript and SCSS changes whenever you save a file. - Ideally, write tests related to your changes. Make sure that all test cases are succeeding (run:
npm run test
). - When you're done, run
npm run production
. - Create a pull request.
Integration with other themes and plugins
lazyload_videos_should_scripts_be_loaded
Filter: You can override when the JS and CSS of this plugin should be loaded. If you always return true
as shown in the example below, the scripts will always be loaded, no matter if the page has a video embed or not.
function custom_theme_plugin__should_scripts_be_loaded($value) {
// return $value;
return true; // <- Always load scripts, no matter what page you're on
}
add_filter( 'lazyload_videos_should_scripts_be_loaded', 'custom_theme_plugin__should_scripts_be_loaded');
lazyload_videos_post_types
Filter: The default set of post types where videos should be lazy-loaded comes from get_post_types(). Use this filter to extend/override the default.