JavaScript to Footer

The Yahoo! Exceptional Performance team recommends placing scripts at the bottom of your page because of the way browsers download components.

"The problem caused by scripts is that they block parallel downloads. The HTTP/1.1 specification suggests that browsers download no more than two components in parallel per hostname. If you serve your images from multiple hostnames, you can get more than two downloads to occur in parallel. While a script is downloading, however, the browser won't start any other downloads, even on different hostnames.

In some situations it's not easy to move scripts to the bottom. If, for example, the script uses document.write to insert part of the page's content, it can't be moved lower in the page. There might also be scoping issues. In many cases, there are ways to workaround these situations."

WordPress default behavior is to load JavaScript in the <head> page.

This plugin will move all javascript code to the footer if the plugins have declared JavaScript properly.

Download

dl WP Figlet

Installation

1. Upload the whole plugin folder to your /wp-content/plugins/ folder.

2. Go to the Plugins page and activate the plugin.

3. Try your blog and check if all plugins work properly. Footer JavaScript may break some plugins so check everything first!

Frequently Asked Questions

How do I correctly use this plugin?

Just enable the plugin and check your blog pages. If all plugins appear to be working correctly you are set!

Additionally you may install YSlow enchancment for Firebug, a popular addon for Firefox browser. YSlow will help you determine your site choke points.

Other

You can also visit my other Wordpress Plugins.

If you are looking for WordPress services, feel free to contact me.

41 Comments

  1. Leah
    4 days ago

    This is a great plugin. Thank you very much. The sites I use it on have more bells and whistles than a train museum as far as API's video, flash, galleries, and jquery menus go. Before I found this plugin, I had to monkey around with 'enqueue_script' and the wp include files to force javascripts into the footer. So far everything works fine and loads much faster. WP version 2.8.6 fyi.

  2. Amanda
    4 weeks ago

    Can't you make an options page so you can disable it for the plugins that break, and move the ones that still work to the footer?

  3. ovidiu
    Oct 7th, 2009

    no news? I guess I'll go back to 0.3 then until this is solved :-(

  4. Romeo
    Oct 3rd, 2009

    Hi Vladimir,
    this plugin is great and really helps with javascript..
    THe only problem is that the plugin brakes some other plugins that use javascript.
    The one that makes me problem is the Tubepress Plugin. Everything works but the videos cannot open with shadowbox or smth like that...

    Can u make the plugin to ignore such pages or smth like that.. It will be really nice to use this plugin but if it stops other pluginis working.. thats not nice...

  5. Deniz
    Sep 29th, 2009

    The last upgrade also broke the Report Post ( http://www.rjeevan.com/en/projects/wordpress/plugins/wp-reportpost ) plugin .

  6. ovidiu
    Sep 25th, 2009

    the last upgrade to 0.4 broke the tubepress plugin: http://wordpress.org/extend/plugins/tubepress/ anything yo ucna do about that?

  7. yann
    Sep 22nd, 2009

    It's working too with only :

    remove_action('wp_head', 'wp_print_head_scripts', 9);
    add_action('wp_footer', 'wp_print_head_scripts', 9);

  8. yann
    Sep 22nd, 2009

    here is the improvment I need to do, having it working on wpmu 2.8.4

    remove_action('wp_head', 'wp_print_scripts');
    remove_action('wp_head', 'wp_print_head_scripts', 9);
    remove_action('wp_head', 'wp_enqueue_scripts', 1);
    add_action('wp_footer', 'wp_print_scripts', 5);
    add_action('wp_footer', 'wp_enqueue_scripts', 5);
    add_action('wp_footer', 'wp_print_head_scripts', 5);

    Can you confirm it ?

  9. Laura
    Jul 15th, 2009

    I installed the javascript to footer plugin and nothing happened. I have 6 scripts. After I installed the plugin I checked on yslow and they are all still in the header. What do I do?

  10. Amanda
    Jun 21st, 2009

    So, how do you "fix" (or otherwise whitelist/exclude) plugins that stop working after you install this?

  11. Bill Gram-Reefer
    Jun 11th, 2009

    Greetings Vlad,

    I am gearing up to upgrade from wp271 to wp28 and read this article by lester chan.

    http://lesterchan.net/wordpress/2009/01/26/loading-javascript-in-footer-in-wordpress-28/

    Since I already use your footer javascript plugin I am wondering if that is or needs to be updated for 2.8?

  12. Strangely
    May 10th, 2009

    Hi Vladamir
    The plugin really speeded stuff up. However, in common with @BTTV;

    The slideshow in NextGen Gallery which uses the JW Image Rotator, doesn't work.
    Shutter Reloaded seems to work okay! ?? Mine's 2.2 the same.

    I can't currently find any other issues, but, I like the NextGen slide show, so my site will just have to be a bit sluggish for now until I get more time to experiment - maybe things will work together in future anyway!

    Thanks for all your good stuff anyway - much appreciated.

  13. BTTV
    May 9th, 2009

    Sorry, it doesn't work with wordpress 2.7.1 and the plugins:

    cformsII 10.5.1
    Comment Quicktags -Reloaded
    Shutter Reloaded 2.2
    Sociable Zyblog Edition 2.0.12
    WP-Polls 2.40

    In my NextGen Gallery the JW Image Rotator from Jeroen Wijering doesn't work.

Have your say

Your email is never published nor shared. Required fields are marked *

*
*

This site rewards regular commentators with do-follows links to their site.

Subscribe without commenting

About Vladimir

vladimir prelovac Hi! My name is Vladimir Prelovac. I am a computer engineer by profession and an adventurer by state of mind.

"I would love to change the world, I just don't have the source code yet."

Books by Vladimir

WordPress Plugin Devleopment Book WordPress Plugin Development: Beginner's Guide

Published by Packt Publishing, available online through Amazon. Click the image for more information.

Consulting Services

Professional WordPress solutions based on custom developed plugins and themes

Expert on-site WordPress SEO consulting and an 'out-of-the-box thinking' approach to problems