Search code examples
wordpresswordpress-jetpack

How to stop Jetpack from loading CSS files from WP.com?


I use Jetpack only for site stats, CDN and security only. I don't need the jetpack.css that is automatically loaded. The extra css file pulls down my pagespeed / pingdom / gtmetrix scores.

The most common solution that is mentioned for stopping the Jetpack css file from loading is to add this code to the functions.php of the theme :

// remove jetpack css
add_filter( 'jetpack_implode_frontend_css', '__return_false' );

// Remove jetpack extra files

function remove_devicepx() {
wp_dequeue_script( 'devicepx' );
}

add_action( 'wp_enqueue_scripts', 'remove_devicepx');
add_action( 'admin_enqueue_scripts', 'remove_devicepx' );

It worked briefly. But since Jetpack got upgraded a couple of days ago, the Jetpack.css file loads up again.

I have tried all possible code snippets and variations I could find on the net, Flushed caches and tried again and again.

I have even gone into the Jetpack individual modules settings and retained only the essential ones - i.e. Lazy load of images, CDN and Security features. None of these require the CSS.

The only solution seems to be to disable Jetpack completely.

Is there a way to stop these two files from loading ?

https://c0.wp.com/p/jetpack/6.9/css/jetpack.css

https://c0.wp.com/c/5.0.3/wp-includes/css/dist/block-library/theme.min.css

Solution

  • Try add_filter( 'jetpack_implode_frontend_css', '__return_false', 99 );

    The temporary solution was found here and the Jetpack team is working on a fix for the bug: https://jetpack.com/2019/01/10/jetpack-6-9-introducing-more-tools-for-the-new-block-editor/