Jetpack is a fantastic plugin for WordPress I’m sure we can all agree on that, there is a lot of debate about the excess bloat and as a developer I have to say Jetpack, as it is, is bloated and can really can bog your site down. One of the biggest problems I see is the conflict of Jetpack modules and built in features on themes. Theme developers should really take Jetpack into account and check to see if Jetpack modules are active and dequeue scripts for conflicting elements.

Below is an example of how we dequeue the Magnific Popup jQuery scripts and styles when the Jetpack Carousel module is active.

[php]
if ( class_exists( ‘Jetpack’ ) && Jetpack::is_module_active( ‘carousel’ ) ) {
wp_dequeue_script( ‘Magnific_popup’ );
wp_dequeue_style( ‘Magnific_popup_css’ );
}
[/php]

 

Remove a Jetpack Module completely

If you a shipping a theme that will have parts built in such as infinite scroll or maybe you have taken time to build an even better version of the Jetpack Carousel, you wont want your theme users to run into problems when activating Jetpack modules that wont be needed. Below is a simple method of removing Jetpack modules that aren’t needed from your site, you can add this a plugin or simply include it in your theme functions. This method is based on Parham Ghaffarian plugin.

[php]

function ah_remove_jetpack_modules( $modules ){
$jp_mods_to_disable = array(
‘related-posts’,
‘manage’,
‘protect’,
‘sso’,
‘mobile-push’,
‘photon’,
‘stats’,
‘gravatar-hovercards’,
‘minileven’,
‘vaultpress’,
‘custom-css’,
‘json-api’,
‘infinite-scroll’,
‘wpcc’,
// ‘shortcodes’,
// ‘widget-visibility’,
// ‘contact-form’,
// ‘shortlinks’,
// ’tiled-gallery’,
// ‘publicize’,
// ‘post-by-email’,
// ‘widgets’,
// ‘comments’,
// ‘latex’,
// ‘enhanced-distribution’,
// ‘notes’,
// ‘subscriptions’,
// ‘after-the-deadline’,
// ‘carousel’,
// ‘sharedaddy’,
// ‘omnisearch’,
// ‘likes’,
// ‘videopress’,
// ‘gplus-authorship’,
// ‘monitor’,
// ‘markdown’,
// ‘verification-tools’,
// ‘custom-content-types’,
// ‘site-icon’,
);
foreach ( $jp_mods_to_disable as $mod ) {
if ( isset( $modules[$mod] ) ) {
unset( $modules[$mod] );
}
}
return $modules;
}
add_filter( ‘jetpack_get_available_modules’, ‘ah_remove_jetpack_modules’ );

[/php]

To remove a module from Jetpack simple remove the comments, in the above example the first 14 modules have been deactivated completely.

Please leave your comments below.