Skip to content

Instantly share code, notes, and snippets.

@davidsword
Last active March 5, 2019 20:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidsword/e699adaadb616d7ff2ac727ecd3c91c5 to your computer and use it in GitHub Desktop.
Save davidsword/e699adaadb616d7ff2ac727ecd3c91c5 to your computer and use it in GitHub Desktop.
WordPress - Jetpack: Enable lazyload Module via functions.php
<?php
/**
* Some Jetpack modules can be manually loaded.
*
* Here's an example of how to enable Lazy Images via code instead of database.
*
* @see https://github.com/Automattic/jetpack/blob/593ee4cccd6aead047c72aa78378f368f084035e/modules/lazy-images.php#L27
*/
if ( defined( 'JETPACK__PLUGIN_DIR' ) ) {
require_once( JETPACK__PLUGIN_DIR . 'modules/lazy-images/lazy-images.php' );
add_filter( 'lazyload_is_enabled', '__return_true' );
add_action( 'wp', array( 'Jetpack_Lazy_Images', 'instance' ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment