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 JavaScript to Footer

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.

Comments:

69 Comments

  1. David Ostrow
    Nov 25th, 2010

    Hi. I have been using the plugin for a while. something happened this week. I went into the plugin editor in word press. I noticed several new lines of code. The challenge is that ti JW image rotator is not working. I really cannot recall when I last update JS to footer plugin, but over the last 2-3 days my slideshow in next gen gallery stopped working. I have traced ti to the JS footer plugin. I looked at the code in version 0.3.1 and see several new lines in 0.4 version. It seems that when I take the line
    remove_action('wp_head', 'wp_print_head_scripts', 9); out the flash works, but the JS stays in the head. I down graded to 0.3.1 and see the the script does not relocate.

    I see great value in this plugin for speed, but cannot have the slide show dysfunctional. I am on wordpress3.0.1, next gen version is 1.6.2. Jw image rotator is the most current version.

    How do we need to modify the code in the plugin to get the slide show to work, and the js to get to the footer?

    the site is fitgolf.com.

    I appreciate your help.

    Dave

  2. intoxi
    Oct 17th, 2010

    Hi,
    it gives any option to ignore an javascript? so it works but one of my plufins need the script in head other one this plugin are broken. Why could i solved this?

    • Oct 17th, 2010

      Unfortunately not. You can try using W3 Total Cache instead

      • Tasver
        Nov 14th, 2010

        This plugin stop embedded video works..
        This bug will be fixed in a future?

  3. Franck
    Oct 12th, 2010

    Sorry, this plugin stop functionnality plugin Embedded Video.
    Solution ?

  4. Tembang Lawas
    Sep 26th, 2010

    very useful plugins thank for share :)

  5. Simon
    Aug 31st, 2010

    Hey Vlad, thanks the plugin helps a lot! I think I have only one thing that broke. I have lazyload declared like this:

    add_action('wp_head', 'jquery_lazy_load_headers', 5);
    add_action('wp_head', 'jquery_lazy_load_ready', 12);

    The lazy_load_headers goes to the footer, the other one stays on top. But they seem to need to be both up there to work. What can I do? Plugin's here: http://github.com/ayn/wp-jquery-lazy-load/

  6. Vivek
    Jul 13th, 2010

    I have installed it on one of my domain, but javascript are still showing in header after such long time. Anything which i miss ?

  7. Ken
    Jul 10th, 2010

    I definitely agree that it would be nice to exclude certain scripts that need to be at the top of the page. This would help users resolve plugins that break when installing this plugin.

    Other than that, this is a great plugin.

    • trusktr
      Jul 11th, 2010

      Yeah, please add this feature vlad!! :D :D :D

  8. Rodrigo
    May 30th, 2010

    Excelent plugin. Increase the website performance. Thanks.

  9. Joe Pea
    May 7th, 2010

    Please let me know if you add this feature!

  10. Joe Pea
    May 7th, 2010

    Would be neat if you could select which scripts to move to the bottom!!

  11. Hassan Arshad
    Dec 27th, 2009

    Hi Vladimir,

    Thank you so much for these great plug-ins. I am having a problem with this one on my site though. When I activated it, it opened and kept open the "View Work" tab on the top of my Website. Just for a future reference.

    Thanks so much again!

  12. babak
    Nov 24th, 2009

    This plugin is great. It really has sped up my site. Strangely, it's adding a smiley face at the end of my footer. Is that by design?

  13. Leah
    Nov 17th, 2009

    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.

  14. Amanda
    Oct 28th, 2009

    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?

  15. ovidiu
    Oct 7th, 2009

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

  16. 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...

  17. Deniz
    Sep 29th, 2009

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

  18. 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?

  19. 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);

  20. 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 ?

  21. 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?

  22. Amanda
    Jun 21st, 2009

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

  23. 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?

  24. 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.

  25. 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 *

*
*

Subscribe without commenting

About

vladimir prelovac Vladimir Prelovac is CEO of Prelovac Media, a computer engineer by profession and an adventurer by state of mind. more +


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

Services

Manage multiple WordPress sites

Built for WordPress enthusiasts, ManageWP helps you manage all your WordPress sites from one central location.

Books

WordPress Plugin Devleopment Book Read my book WordPress Plugin Development: Beginner's Guide

Published by Packt Publishing, available online through Amazon.