WordPress.org

Ready to get started?Download WordPress

Forums

prototype.js is evil ;) (8 posts)

  1. Bodhipaksa
    Member
    Posted 5 years ago #

    Okay, prototype.js is no doubt useful and even essential for the admin area of WordPress, but you may find, as I did, that you're inadvertently slowing down your site by a huge amount by using certain plugins that call this massive script.

    The problem: prototype.js is a whopping 124kb. I found that each page on my site, once you added up all the html, css, images, and scripts, was coming in at half a megabyte. That's ludicrous. And half of the size was due to prototype.js. Even optimizing this script by stripping out all the whitespace leaves it at 92kb.

    After doing a little research I found that there were certain plugins that were calling this script:

    1. Podpress
    2. Share this
    3. Collapsible Archive Widget
    4. Sociable

    Now I like Alex King's Share This plugin, for example, but I had to decide whether the annoyance of visitors having to download half a megabyte was balanced by the benefits few people that actually use that plugin. I decided it wasn't.

    Two of the other plugins were disabled (I've just listed them to be informative). The fourth was one I'd just installed but hadn't started using.

    I also found that a plugin was adding a call to jquery.js to every page, when I only needed it on the home page. So I wrapped that in a conditional tag so it only appears when needed.

    Anyway, I'd suggest looking in the code view of your browser and seeing if prototype.js is being called. If it is, you might want to decide whether fast-loading pages are more beneficial to your site's visitors than the benefits of the plugins you're using.

    My pages are now about 40kb (much better than 500kb!) and load very quickly.

    Anyone else found plugins that call prototype.js?

  2. Justin Tadlock
    Member
    Posted 5 years ago #

    Many, many plugins use Prototype. If we could just move everything over to jQuery, it'd be great because it's much lighter.

    The problem usually isn't that a user is using a plugin that utilizes Prototype. The problem is that they're using plugins that use jQuery, Prototype, MooTools, and so on, when they should really only be using one JavaScript library at most.

    Most users aren't informed enough to know that this will slow down their site considerably.

  3. Bodhipaksa
    Member
    Posted 5 years ago #

    Most users aren't informed enough to know that this will slow down their site considerably.

    That's the problem. And that's why I wanted to post something here so that people discovering this mysterious call to prototype.js in their headers would be able to get some background information.

    And so that users can be informed it would be good to know which plugins use that script.

    The problem usually isn't that a user is using a plugin that utilizes Prototype.

    Whether that's "the" problem I can't say, but on my site it was "a" problem. I'm so happy to have my site running well again! I'll be interested to see what effect it has on traffic.

  4. imagiscapeca
    Member
    Posted 5 years ago #

    My admin post-new page calls BOTH
    wp-includes/js/prototype.js 121 KB
    wp-includes/js/prototype.js?ver=1.6 121 KB

    and ALSO calls BOTH
    jquery.js 30 KB
    jquery.js?ver=1.2.6 30 KB
    ( and jquery.form.js 31 KB )

    How can I find which plugin(s) is(are) calling the redundant scripts?

    Is prototype essential for the admin area?

    My public homepage calls
    prototype.js?ver=1.6 121 KB
    jquery.js?ver=1.2.6 30 KB
    jquery/ui.tabs.js?ver=1.5.1 6 KB
    jquery/jquery.color.js?ver=2.0-4561 4 KB
    jquery/ui.core.js?ver=1.5.1 4 KB
    jquery/jquery.schedule.js?ver=20 3 KB
    tw-sack.js?ver=1.6.1 5 KB

    Should I replace the call for tw-sack.js with jquery (since I already need to call jquery)?

    Also 378 KB was being downloaded from cocomment:
    cocomment.com/js/integration.v2.full.js 179 KB
    cocomment.com/js/extension.v2.full-2.6.3.505.js 173 KB
    cocomment.com/ClientInitializeServlet?[...] 15 KB
    cocomment.com/jsm/268441600.536872960-2.6.3.505.js 14 KB
    cocomment.com//js/extender?ignoreGenericPages&[...] 4 KB
    cocomment.com//js/extender?ignoreGenericPages&[...] 4 KB
    cocomment.com//js/extender?ignoreGenericPages&[...] 4 KB

    Removing coComment Enhancer (1.2.3b) saved all these.

    Thanks. Down with evil.

  5. imagiscapeca
    Member
    Posted 5 years ago #

    Haecceity wrote

    I also found that a plugin was adding a call to jquery.js to every page, when I only needed it on the home page. So I wrapped that in a conditional tag so it only appears when needed.

    I know the conditional tag "if is_home()", but if the script is needed on a few dozen posts, with more being added occasionally, can conditional tags help? Is there a way to get scripts called only on pages which use the plugin?

    Can I get the scripts to load not in wp_head() but in the midst of loading the page?

    For example, I only need these called on a few pages:
    plugins/anarchy_media/anarchy_media_player.php?anarchy.js 25 KB
    plugins/wp-table/tablesort.js 24 KB
    plugins/wp-polls/polls-js-packed.js?ver=2.31 3 KB

  6. imagiscapeca
    Member
    Posted 5 years ago #

    This is such a cool and important thread. Hey everyone! Read this! (If nothing else, read the last two posts by imagiscape)

  7. rrhobbs
    Member
    Posted 5 years ago #

    when I am editing posts on one of my sites lately it takes what seems like FOREVER to save, it's hanging on JQuery and if I view source on my edit page there are a considerable number of javascript calls - hope eventually there will be a little more law and order in this area... thx

  8. chewru
    Member
    Posted 5 years ago #

    Here's a really, really, really easy way to reduce the file size.

    Go to http://www.scriptalizer.com .. upload prototype.js .. it will reduce it 43% just like that.

    Javascript Filesize summary:
    Size before: 121.23 KB
    Size after: 70.91 KB
    50.32KB SAVED!

    Save the file back to your PC.. rename it back to prototype.js.. and overwrite your old one .. (backing it up of course).

Topic Closed

This topic has been closed to new replies.

About this Topic