

If you plug your page into a tool like Google’s PageSpeed insights for example, it’ll complain that a lot of stuff is preventing the page from displaying – and those tools will be right. This will place a element in the head that looks like this:Īs mentioned earlier, this CSS stylesheet is render blocking. Most CSS in WordPress is (and should be) enqueued properly using the “wp_enqueue_style” function. The tool will scan your website and eventually give you a blob of text like this:Ĭopy this and keep it safe. For now, just visit a site like like, enter your site’s URL or page, and click “Generate Critical Path CSS”. The importance of this step will become evident after step 2.

Unfortunately, this has some side effects that we need to take care of. So it’s a best practice to defer them ( not the same “defer” as with Javascript though). Which means that the browser doesn’t proceed until they’ve been downloaded. Normally, all externally linked CSS stylesheets are render-blocking. While it doesn’t improve your page load time, it makes a huge difference to how the user perceives the page to load.
#WORDPRESS DISABLE LINK CSS HOW TO#
Of course, there is like a 100% chance that WordPress will change how these REST API functions operate, so most likely these techniques will need updating at some point in the future.Knowing how to inline and defer CSS on your WordPress site is a vital part of improving the viewer experience. You can add that magic slab via theme template or custom plugin and call it good. Remove_action('template_redirect', 'rest_output_link_header', 11, 0) Remove_action('wp_head', 'wp_oembed_add_discovery_links', 10) Remove_action('wp_head', 'rest_output_link_wp_head', 10) Putting these three techniques together, we get the following chunk of code: // Disable REST API link tag Remove_action('template_redirect', 'rest_output_link_header', 11, 0) All Together This header can be disabled by adding the following line to functions.php: WordPress 4.4 adds the following link header to all page requests: Remove_action('wp_head', 'wp_oembed_add_discovery_links', 10) Disable REST API link in HTTP headers WordPress 4.4 adds the following oEmbed discovery links to all single-view pages: Remove_action('wp_head', 'rest_output_link_wp_head', 10) Disable oEmbed Discovery Links This markup can be disabled by adding the following line to functions.php: WordPress 4.4 adds the following link tag to all front-end pages: So now let’s look at each of these three items and see how to disable them. Honestly I’m not sure if the oEmbed links are considered a part of the REST API, but they look similar, appear in the same location, and were introduced at the same time as the other REST stuff, so I’m gonna include it here.
#WORDPRESS DISABLE LINK CSS CODE#
This article explains how to disable three bits of code that WordPress now adds to front-end pages: If you want/use the REST API, then by all means knock yourself out and don’t disable it. One way to do this is to disable unnecessary code.īut hey, to each their own. I like to keep things lightweight, fast, and relevant. For example, none of my sites use any of the REST API stuff. Why would someone want to do this? Because not everyone uses or wants the WP REST API, so the link headers and related markup are not always necessary. That is, only disable if you know what you are doing ) Why? Note: before implementing any of these techniques, make sure that your site does not need any of the REST API stuff in WP 4.4. This tutorial explains how to disable it. But if not, then you may want to remove all of the extra baggage that WordPress now adds to every page load. WordPress 4.4 adds all sorts of new REST API functionality.
