[WordPress] Improve performance by removing cookies from static resources

For several years now, Google has taken performance into account to create its ranking (even if it seems to be very low). But generally speaking, it is known that a fast site gets better results.

cookies

In other words, the hunt for the millisecond is open. I had also installed the Parallelize plugin for WordPress, in order to distribute the downloading of images on 2 subdomains. But I also noticed that all my blog images are loading with the huge WordPress cookie.

How to distribute static resources without cookies with WordPress?

It's actually fairly easy. Just open your file wp-config.php, at the root of your WordPress blog, and insert the following code (adapting it to yours of course):

define('WP_CONTENT_URL', 'http://img1.websourcing.fr/wp-content'); define('COOKIE_DOMAIN', 'blog.websourcing.fr');

The first line contains the domain that points to your static content (usually used with bloginfo(‘template_directory’)). The second contains the domain that should be served with the cookie.

I use the subdomain img1 to render non-generated images, style sheets and JS, sprites in my style sheet, …
There is no huge difference, but few bytes less on each static resource that you will process like this. Added together, this can represent a certain weight (a few KB if you have a lot of images).

You'll find plenty of threads about this on the WordPress.org forums.

Also read