• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Tips and Tricks HQ

  • Home
  • Blog
  • Projects
    • All Projects
    • Simple WP Shopping Cart
    • WP Express Checkout Plugin
    • WP Download Monitor
    • WP Security and Firewall Plugin
    • WP eStore Plugin
    • WP Affiliate Platform
    • WP eMember
    • WP Lightbox Ultimate
    • WP Photo Seller
  • Products
    • All Products
    • Checkout
  • Support
    • Support Portal
    • Customer Only Forum
    • WP eStore Documentation
    • WP Affiliate Software Documentation
    • WP eMember Documentation
  • Contact

2 Simple WordPress Blog Optimization Tips and Tricks

You are here: Home / Web Development / Site Optimization Tips / 2 Simple WordPress Blog Optimization Tips and Tricks

Last updated: September 2, 2009





I have been pretty busy with the WordPress plugin development lately, so didn’t get a chance to write any posts for a few weeks. I think it’s about time I share a simple but effective website performance improvement trick with the readers of this site that I have been using on all my sites. If you haven’t read the WordPress site optimization tips and tricks already then you should read that first.

This trick involves changing some of the dynamic wordpress queries to static ones which in turn reduces the number of database queries and improves site performance. This does require a little bit of PHP knowledge but it’s really basic stuff.

In your WordPress theme’s header and footer you will see many statements similar to the following:

bloginfo(‘home’)

This queries WordPress for the home URL of your blog (eg. http://www.your-site.com). Now, how often do you think your home URL is going to change? Most likely never! So why not replace it with the static information which is “http://www.your-site.com” and make one less database query?



Saving one database query may not sound very convincing but you probably have many statements like the following that can also be replaced:

bloginfo(‘html_type’)
bloginfo(‘charset’)
bloginfo(‘name’)
bloginfo(‘version’)
bloginfo(‘stylesheet_url’)
bloginfo(‘rss2_url’)
bloginfo(‘template_directory’)
bloginfo(‘home’)

Now multiply that by every page load per visitor. This in turn can save thousands of extra database queries depending on the number of traffic you get and improve your site’s performance a little. When you are on a shared hosting plan (which most of you will be when you first start out) it helps increase your page load time and also takes a little bit of pressure off the CPU.

How to go about doing this?

It’s just a matter of finding what each one of these queries retrieve from the database then replace that query string with the static info. I normally “echo” the output of all these queries and then take that output and replace the query with it. You can probably put the following in one of your theme’s file and find what the output of each one of these queries are then simply search and replace them:

echo bloginfo(‘html_type’);
echo bloginfo(‘charset’);
echo bloginfo(‘name’);
echo bloginfo(‘version’);
echo bloginfo(‘stylesheet_url’);
echo bloginfo(‘rss2_url’);
echo bloginfo(‘template_directory’);
echo bloginfo(‘home’);

This link has a few examples and can be useful when doing this.

Move Javascript at Bottom of the Page

Your site can run very slow or stall if another site that you call Javascript from is down. Moving the Javascript to the bottom of the page allows your visitor to still see your page content even though the javascript at the bottom is not loading for some unknown reason.

Moving the javascript to the bottom of the page is a common tip but I sometimes get asked the following question:

“How do I move Javascript to the bottom of the page exactly?”

So I am going to quickly cover this here. There may be exceptions where you specifically want to load the javascript in the header but generally it should be moved to the bottom of the page (footer of your theme). The HTML code to load a javascript looks similar to the following:

<script type=”text/javascript” src=”http://www.your-site.com/wp-content/themes/theme-name/scripts/some-script-file.js”></script>

So you can open your theme’s “header.php” and search for the word “javascript”. Once you find a line similar to the one above, cut that full statement (opening tag to end tag) and paste it in the “footer.php” file.

Related Posts

  • How to Add Far Future Expires Headers to Your WordPress Site
  • Top 15 Search Engine Optimization (SEO) Techniques I Forget to Do
  • WordPress Optimization Tips and Tricks for Better Performance and Speed
  • How to Add Widgets to WordPress Theme’s Footer

Site Optimization Tips Site Optimization Tips,  Web Development,  web masters,  Wordpress

Reader Interactions

Comments (21 responses)

  1. Towid Nategheian says:
    March 2, 2012 at 5:30 am

    first trick is certainly useful for CPU optimizing. but second one is a common html page optimizing trick.
    of all ways of optimizing a WP page Caching was best. also using gzip greatly increases performance.

  2. Colorado SEO Consultants says:
    July 21, 2011 at 5:32 am

    Brilliant yet simple tips! I’m surprised there isn’t a plug in in WordPress to find and replace all these query items for you. I can imagine it would speed up a popular blog very much.

  3. Mark Sim says:
    June 13, 2011 at 11:25 pm

    You should try not to put the JavaScript code at the bottom of a page. It will take some time for the code to load and your website may not look completed when a visitor is looking at it. Thank for the WordPress blog optimization tips, though.

  4. aurora chiropractic says:
    June 9, 2011 at 2:27 pm

    This improved my blog layout very much, thanks for those 2 tips

  5. smhcarhire says:
    May 16, 2011 at 8:16 am

    Nice tips and easy to implement..thanks for sharing

  6. sam says:
    February 21, 2011 at 5:09 pm

    these tips are really good and quick to implement, thanks for that!

  7. Matt says:
    January 10, 2011 at 1:30 pm

    This is great material and has helped me in several ways. I have tried to find this information elsewhere, but other sites just confuse things and make them harder than they actually are. Thanks for the help!

  8. John Gamings says:
    January 3, 2011 at 10:51 am

    Nice tips. Unfortunately, this can make your theme nonportable, which can be a real hassle. Still interesting though

  9. tanhak says:
    May 22, 2010 at 2:19 am

    i have so many problems in my website .. getting so many times in loading

    can any one friendly solve it .. i send it header.php and footer.php .. can he sets to me in a right way .. please ..

  10. admin says:
    April 10, 2010 at 3:33 am

    If it’s a plugin then it’s best to request the plugin developer to do it otherwise the changes you make will get lost during an upgrade of that plugin.

    But if you want to change the code of the plugin then look for a line similar to this:

    add_action('wp_head', 'function_name....');

    You will see in the “function_name….” it has included those scripts. Simply move them to the footer using another action called “wp_footer”.

  11. Amber says:
    April 10, 2010 at 2:40 am

    I was able to move the jscript to the bottom of my theme file, but Yslow tells me two e-commerce plugin files still have jscript at the top. Where should the script be moved when it’s in one little plugin file like that?

  12. Amber says:
    April 10, 2010 at 2:08 am

    If yslow is telling me that jscript from a plugin is in the page header, (for example, “http://www.nsvintage.com/main/wp-content/plugins/wp-e-commerce/share-this.php”), to where should that jscript be moved?

  13. Jasmin says:
    March 10, 2010 at 7:37 am

    Thanks for the grat work. After searching nearly 1 hour I found what I was looking for.)

  14. 2base tl says:
    January 7, 2010 at 12:22 pm

    I found your blog on google and read a few of your other posts. I just added you to my Google News Reader. Keep up the good work Look forward to reading more from you in the future.

  15. Charles says:
    January 4, 2010 at 11:17 am

    I’ve always wondered if WP super cache interfered with Adsense on a page. If the whole page is made static then the ads won’t change??

  16. admin says:
    November 22, 2009 at 8:01 pm

    WP Super Cache is really good and has it’s usage but remember there is no one solution that fits everyone’s need. For example, I don’t use wp super cache myself because of other complications.

  17. Bob says:
    November 22, 2009 at 9:01 am

    I wouldn’t recommend doing this! This makes your theme non-portable. Also, if you relocation your blog, e.g. directory change, change to domain (www.mydomain.com to blog.mydomain.com, etc.), you’ll be in trouble.

    If you’re worried about performance, just enable wp-cache or wp-super-cache.

    Don’t tweak your theme, stay generic

  18. Jane says:
    November 7, 2009 at 10:18 am

    The tips are very helpful for me. Thankyou.

  19. Caroline says:
    November 7, 2009 at 10:16 am

    Thanks for sharing. I really like this blog!

  20. John Michael says:
    October 14, 2009 at 6:30 pm

    Wonderful tips ..

    thank you
    regards
    john

  21. Kenny Meyer says:
    September 23, 2009 at 10:02 am

    Thanks for sharing this… I like tweaking my wordpress-blog and this is very helpful in doing so.

Leave a Reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Featured & Popular Articles

Video Answers to Top WordPress QuestionsWordPress Optimization Tips and Tricks for Better Performance and SpeedEssential WordPress Security Tips - Is Your Blog Protected?WordPress Simple PayPal Shopping Cart PluginTop 15 Search Engine Optimization (SEO) Techniques I Forget to DoList of the Best and Must Use WordPress PluginsHow do I Start a Blog and Make Money Online?Good Domain Name Picking Tips for Your Blog SetupFind Out Which WordPress Web Hosting Company Offers the Cheapest and Reliable Web Hosting Solution

Featured WordPress Plugins

wordpress estore plugin
wordpress membership plugin
WP Express Checkout Plugin
WordPress Lightbox Ultimate Plugin
WordPress photo seller plugin
wordpress affiliate plugin

Recent Posts

  • Accept Donations via PayPal from Your WordPress Site Easil [...]
  • Buy Now Button Graphics for eCommerce Websites [...]
  • Subscription Button Graphics for eCommerce Websites [...]
  • Adding PayPal Payment Buttons to Your WordPress Sidebar Ea [...]
  • PayPal QR Codes [...]

Comment & Socialize

  • @Rodrigo Souza, Thank you f ...
    - admin
  • The example for 'slm_add_ed ...
    - Rodrigo Souza
  • @Ron, All the valid transac ...
    - admin
  • Hello, when people have sel ...
    - Ron
  • We have hte following featu ...
    - admin

Check out our solutions

View our WordPress plugin collection and start using them on your site.

Our WordPress Solutions

Footer

Company

  • About
  • Privacy Policy
  • Terms and Conditions
  • Affiliate Login

Top WordPress Plugins

  • Simple Shopping Cart
  • PayPal Donations
  • WP Express Checkout
  • WP eStore
  • WP eMember

Blogging Tips

  • How to Start a Blog
  • Selecting a Good Domain
  • Cheap WP Hosting
  • WP Video Tutorials
  • Simple SEO Tips

Search


Keep In Touch

Copyright © 2023 | Tips and Tricks HQ