Top Spacer

5 WordPress Speed Tweaks

1. Shrink your images…. Here is a good free website that wil do that for you imageoptimizer

Image Compressor1 5 Wordpress Speed Tweaks
2. Use Expire Headers for your files & images, you can copy and paste this script below to your htaccess file:

# BEGIN Expire headers
<ifmodule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/javascript "access plus 216000 seconds"
ExpiresByType application/x-javascript "access plus 216000 seconds"
ExpiresByType text/html "access plus 600 seconds"
ExpiresByType application/xhtml+xml "access plus 600 seconds"
</ifmodule>
# END Expire headers

3. Minify & shrink your CSS and JavaScript. The Minify CSS portion is a bit easier then Javascript minify, simply copy your plugins CSS files to your theme css after you deregister the file(I will explain this below). What does this this do? Reduces HTTP requests, instead of having queries/requests

made for your theme css and every plugins css file when your site is loaded, in my case that would be 40 calls/40 queries, you will have just one. Compressing Javascript Go to plugin, click “edit” search for “.js” ending files, copy or cut, the codes and paste them here jcompress, hit compress & paste your new shrunk code back & update.

Javascript compressor 320x199 5 Wordpress Speed Tweaks
  Compressing CSS For plugins that have long & necessary CSS files(I will also get into this more below), follow the same steps “.css” copy or cut, the codes and paste them here csscompress, hit compress & paste your new shrunk code back & update.

CSS Compressor 5 Wordpress Speed Tweaks
  4. Use cache plugin, personally I have tried W3 Total Cache, WP Super Cache and Quick Cache. I did find W3T Cache to be by far the best all-in one fully featured caching plugin for wordpress. W3TC has every feature you could possible ask for (Some users have reported that W3T does not always play nice with other plugins), if you are one of those users, go with Quick Cache, it will play a lot nicer with multiple plugins. A killer combo recommendation that will get you as close to the w3T cache plugin as possible is Quick Cache, DB Cache Reloaded Fix & WP Minify. Speaking of cache, adding cache control headers can also help, here is another script you can add to your htaccess file:

# BEGIN Cache-Control Headers
<ifmodule mod_headers.c>
<filesmatch ".(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</filesmatch>
<filesmatch ".(css)$"> Header set Cache-Control "max-age=604800, public, must-revalidate"
</filesmatch>
<filesmatch ".(js)$"> Header set Cache-Control "max-age=216000, private"
</filesmatch>
<filesmatch ".(x?html?|php)$"> Header set Cache-Control "max-age=600, private, must-revalidate"
</filesmatch>
</ifmodule>
# END Cache-Control Headers

5. Last but not least, deregister your plugins scripts on your functions.php file. A lot, if not most plugins like to add unecessary css styles to your beautiful blog, so let’s go ahead and deregister them.

Step 1: Go to your plugins, click “EDIT” search (cntl +F) for this code in your plugins file, “wp_enqueue_style” and find the handler that is calling upon this plugin (the code next to “wp_enqueue_style” in (parenthesis)..

Example: I searched for “wp_enqueue_style” in a plugin called “please stop putting unnecessary scripts in plugins”

and I find this=

wp_enqueue_style( 'stop-putting-unnecessary-scripts-in-plugins-css' )

The handler here is = ‘stop-putting-unnecessary-scripts-in-plugins-css’

Step 2: So I copy all the codes in ‘stop-putting-unnecessary-scripts-in-plugins-css’ file and paste it to my theme’s CSS file (usually style.css). This is not always necessary, then I head over to my functions.php file, click edit & paste the following code.

Step 3:

add_action( 'wp_print_styles', 'my_deregister_styles', 100 );

function my_deregister_styles() {
wp_deregister_style( 'stop-putting-unnecessary-scripts-in-plugins-css' );
// deregister as many stylesheets as you need
}

Let’s just say I wanted to deregister 3 more css files from “please stop putting unnecessary scripts in plugins” plugin.

Find handler, you can copy the code to your theme’s CSS, not always needed & deregister it.

add_action( 'wp_print_styles', 'my_deregister_styles', 100 );

function my_deregister_styles() {
wp_deregister_style( 'stop-putting-unnecessary-scripts-in-plugins-css' );
wp_deregister_style( '1-no-purpose-css-codes-css' );
wp_deregister_style( '2-seriously-why-add-useless-css-codes-to-plugins-css' );
wp_deregister_style( '3-another-useless-code-css' );
}

Let’s move on to javascript. SAME EXACT THING EXCEPT WE ARE SEARCHING FOR “wp_enqueue_script”

Deregistering JavaScript can be more meaningful given they are usually more useless then the unnecessary CSS, but cause conflicts Jquery, which by the way is already built in to WordPress so it doesn’t need to be loaded once again. For fun purposes, let use “please stop putting unnecessary scripts in plugins” plugin.

This is what the deregister in functions look like:

function my_deregister_javascript() {

wp_deregister_script( ‘I-serve-no-purpose-js’ );
wp_deregister_script( ‘I-load-already-loaded-jquery-to-your-blog-js’ );
wp_deregister_script( ‘hi-im-jquery-conflict’ );
}

With CSS, deregister all after you copied the file to your theme CSS, with Javascript deregister 1 by 1 to test and see if your plugin has been affected by it, if you have any trouble with this Let me know because my plugin “please stop putting unnecessary scripts in plugins” is currently under development.


tony porto 5 Wordpress Speed Tweaks

Author:Tony Porto

Kansas City full-service web design studio. Web Developer & SEO enthusiast.



Related posts:
No comments yet

Got something to say? Go for it!