How to Disable Unnecessary CSS and JavaScript in a WordPress Theme (Without Breaking Everything)
Want to make your WordPress site lightning-fast and reduce unnecessary code bloat? If you’re building a custom theme or a lean landing page, removing scripts like jQuery, emoji support, RSS feeds and block styles can help clean up the output HTML — but only if you’re sure you don’t need them.
Prefer watching over reading? You can check out the full tutorial on YouTube in the player below.
Or if you’re more of an old-school type who likes a proper walkthrough in text — just scroll down.
Table of Contents
- Why Clean HTML Matters
- What You Can (Safely) Remove
- How to Disable Unwanted Assets
- Before You Strip Everything
- Final Thoughts
1. Why Clean HTML Matters
Every time a browser loads your site, it downloads all scripts, styles, and metadata injected by WordPress and its plugins. This can easily add up to dozens of HTTP requests, especially if you’re using a bloated theme.
Stripping unnecessary assets helps with:
- Faster load times
- Better SEO
- Greater control
- A minimalist codebase
2. What You Can (Safely) Remove
Asset | Description | Safe to remove if… |
---|---|---|
jQuery, jquery-migrate | Legacy dependency for plugins and themes | Your theme/plugin does not use jQuery |
Emoji scripts and styles | Emoji detection and rendering JS | You’re not using emojis in content |
wp-block-library-css | Gutenberg block styles | You’re using Classic Editor or custom layout |
Inline theme styles | Styling presets for themes | You’ve fully overridden them |
RSS feed links | For syndicating content | You don’t need feeds |
oEmbed and JSON API | Enables embedding from/into WP | You don’t use oEmbed or REST endpoints |
WP Generator meta tag | Shows WP version | Security best practice is to hide it |
3. How to Disable Unwanted Assets
Add the following snippets to your theme’s functions.php
file or a custom plugin.
Remove jQuery and jQuery Migrate
function ozwebexpert_dequeue_jquery() {
if (!is_admin()) {
wp_deregister_script('jquery');
wp_deregister_script('jquery-migrate');
}
}
add_action('wp_enqueue_scripts', 'ozwebexpert_dequeue_jquery', 100);
Disable Emoji Scripts and Styles
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_filter('the_content_feed', 'wp_staticize_emoji');
remove_filter('comment_text_rss', 'wp_staticize_emoji');
remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
Disable Gutenberg Block CSS
function ozwebexpert_remove_block_css(){
wp_dequeue_style('wp-block-library');
wp_dequeue_style('wp-block-library-theme');
wp_dequeue_style('global-styles');
}
add_action('wp_enqueue_scripts', 'ozwebexpert_remove_block_css', 100);
Remove RSS Feed Links
remove_action('wp_head', 'feed_links', 2);
remove_action('wp_head', 'feed_links_extra', 3);
Disable REST API, oEmbed, and RSD Links
remove_action('wp_head', 'rest_output_link_wp_head');
remove_action('wp_head', 'wp_oembed_add_discovery_links');
remove_action('wp_head', 'rsd_link');
Hide WordPress Version
remove_action('wp_head', 'wp_generator');
Remove Blankslate stuff
//
add_action('after_setup_theme', function() {
// Remove user-agent sniffer
remove_action('wp_footer', 'blankslate_footer');
// Remove comment-reply.js
remove_action('comment_form_before', 'blankslate_enqueue_comment_reply_script');
// Remove notice “Thank you for using BlankSlate!”
remove_action('admin_notices', 'blankslate_notice');
remove_action('admin_init', 'blankslate_notice_dismissed');
});
4. Before You Strip Everything
Don’t remove assets just because someone on a forum said it makes things faster. A few reminders:
- If you’re using Contact Form 7, sliders, or WooCommerce — you probably still need jQuery.
- Stripping emoji support may cause emojis not to render properly.
- Disabling oEmbed or REST API can break integrations with Zapier or social embeds.
Test your site thoroughly after making changes:
- Open pages in multiple browsers and devices
- Check console for errors
- Validate forms, embeds, and interactive elements
5. Final Thoughts
Cleaning up your WordPress theme from unnecessary scripts and styles is a great way to speed things up and stay in control — but don’t overdo it. Remove only what you’re confident you don’t need.
If your goal is a custom theme with clean HTML output, these tips will help — just remember: less isn’t always better if it breaks your site.
Need help building a lightning-fast WordPress site tailored for the Australian market? I’d love to chat.