Menu Close

Removing devicepx-jetpack.js for WordPress

The JetPack is a Automatic’s do-everything plugin for WordPress. It includes a script, devicepx-jetpack.js, which is meant to serve bigger avatar images for high resolution screens.

If you are using Jetpack plugin by Automattic,you will see that different modules in the plugin load different files,however if you are not using the modules it doesn’t loads any file but still if you will check you will observer that a file name “devicepx-jetpack.js” keeps loading even if all the modules are deactivated.

Because the devicepx-jetpack.js file is not loaded by any Module but it’s part of the Jetpack core files,and their isn’t any option to disable it,however you can disable it but before that let see what does devicepx-jetpack.js do.

devicepx-jetpack.js loads retina/HiDPI versions of files (Gravatars etc) for devices that run at higher resolution and personally i don’t think that it’s necessary to keep it. This is annoying because it’s an extra script call which increases the page’s weight.

The lines in question from jetpack.php:

/**
* Device Pixels support
* This improves the resolution of gravatars and wordpress.com uploads on hi-res and zoomed browsers.
*/
function devicepx() {
wp_enqueue_script( ‘devicepx’, ( is_ssl() ? ‘https’ : ‘http’ ) . ‘://s0.wp.com/wp-content/js/devicepx-jetpack.js’, array(), gmdate(‘oW’), true );
}

The script goes by the handle devicepx, so that’s what we need to turn off. To do so, add the following to your theme’s functions.php file:

function remove_devicepx() {
wp_dequeue_script( ‘devicepx’ );
}
add_action( ‘wp_enqueue_scripts’, ‘remove_devicepx’ );