This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
Optimising WordPress for SEO by removing default assets
If you’re working on a fully bespoke WordPress theme, there are a number of default assets you can likely remove from WordPress to streamline the loading times of your new site.
Out of the box, WordPress loads a number of stylesheets and script files that you are unlikely to require if you’re working on a fully bespoke WordPress theme. The code snippet below removes non-essential assets such as emoji styles, support for oEmbeds when linking to other WordPress sites (introduced in WordPress 4.4) and styles for the Gutenberg Block Library that WordPress has shipped with since 5.0.
Lowering the number of individual asset files that are required to be downloaded and parsed before your site can load is likely to have a positive effect on your PageSpeed Insights score.
/**
* Remove junk
*/
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
/**
* Remove unnecessary scripts
*
* @return void
*/
function deregister_scripts() {
wp_deregister_script( 'wp-embed' );
}
add_action( 'wp_footer', 'deregister_scripts' );
/**
* Remove unnecessary styles
*
* @return void
*/
function deregister_styles() {
wp_dequeue_style( 'wp-block-library' );
}
add_action( 'wp_print_styles', 'deregister_styles', 100 );