Support » Plugins » A plugin to detect javascript duplicates?

  • googlebot


    I have few plugins active and I noticed that some of them add to the header the same javascript multiple times, for instance, I have scriptacolous referenced 3 times by 3 different plugins. Wouldn’t that slow down a bit the loading time?
    Is that a normal behavior?

    So, I was wondering if there is any plugin to do a clean up in the header, detects any javascript duplicate and removes it.


Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Samuel Wood (Otto)

    (@otto42) Admin

    WordPress itself eliminates these duplicates, in the latest versions. Of course, this is assuming that these plugins are correctly using the WP_Script functions.

    Basically, a plugin can add a javascript to WordPress, tell it what dependencies the script has (on other scripts), etc. Like if you have a JS that needs scriptaculous, you can add that script and tell WordPress that it needs scriptaculous. Then, you can “enqueue” it when you need it. WordPress will automatically output the necessary script tags to load the script into the page, along with it’s dependencies.

    In other words, tell the plugin authors to fix their plugins to use the new WordPress functionality that was developed specifically to prevent this sort of thing. Scriptaculous and jQuery are both included in the latest WordPress, they don’t need to be including them with their plugins anymore, they should use the existing versions by using the wp_enqueue_script functionality.

    Also, if you find a plugin that is not using this functionality and is loading it’s own javascript directly, then please post it and tell everybody, because this means that it’s likely *not* wholly compatible with the latest versions of WordPress (2.2 and up).



    Awesome, thanks.

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    Since it’s not documented particularly well, I added some starter documentation to the codex, so that people can figure out how to use the scripts functionality:

    I can see which scripts are called, but I can’t see which plugins are calling them!

    How can I find which plugin is calling the script?

    I have Firefox Extensions:

    • JSView (!)
    • Web Developer
    • Firebug
    • ViewSourceWith
    • View Source Chart

    I hope to find not only which plugins call jsquery, but ALSO which call it in the wrong way that leads to duplicate loads.

    If I search all my plugins’ code, is there a tell-tale sign of incorrect code?


    Still seeking …

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘A plugin to detect javascript duplicates?’ is closed to new replies.