Removing devicepx-jetpack.js for WordPress

I’m running JetPack, 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.

This is annoying because it’s an extra script call which increases the page’s weight. I couldn’t find any easy guides for removing it, so here’s one.

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' );

That does the trick.