Load jQuery only if it is not already loaded on a site

The following script http://widget.fotomoto.com/javascript... has a file size of 249KB, part of the reason why this is huge is that it include jQuery 1.4.2 library in that file. It is quite common nowadays to have jQuery loaded on a site, it would be great if you could change the logic on your end so that:

1. it loads a version without jQuery library appended to it
2. loads jQuery library in another file if it is not already loaded on the site.
2 people like
this idea
+1
Reply
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated

  • Ahmad (Official Rep) July 06, 2010 08:04
    There is a problem with this. There are different versions and flavors of jQuery, so we also have to check the version of jQuery, which is not always possible (it does NOT always return the correct value).

    Also, every communication with the server slows down the loading time / process. We have done a lot of testing and over all, we believe loading jQuery in our script is the fastest way to do this. And when the user loads our script once (which is compressed and about 60K, not 200+K), it gets cached in the browser.

    --Ahmad
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated

  • I’m frustrated
    I realize this topic was opened 4 years ago, but the problem still remains. I too already have jQuery loaded on my page, and it appears the Fotomoto JS literally includes jQuery v1.6.2 in it's code causing the js file to be much larger than it needs to be.

    There are a few problems with this: 1. I am now locked into to using that version of jQuery and cannot upgrade unless Fotomoto upgrades jQuery, 2. Including a library more than once can cause issues and referential problems, 3. Unnecessarily increases page weight and load times, and 4. If Fotomoto decides to upgrade jQuery to a newer version in it's code that is not compatible with my site or the version of jQuery I use, then that could blindly break my site and cost me money and labor to fix.

    There most definitely should be a configuration option to exclude jQuery from the Fotomoto JS either from the Fotomoto Dashboard, JS code, or in my case, an option on a settings panel on my Wordpress Fotomoto plugin. Is there not anyway to exclude jQuery from the Fotomoto JS at all?

    This seems like an extremely flawed design and could potentially cause my site to break in the future, not to mention it currently causes slower load times. Also, I'm not a lawyer and don't know much about licensing, but this could potentially be a legal issue too. Including someone else's entire library in your code may be a breach of some kind of licensing agreements. Nonetheless, I've been a software engineer for over a decade now, and I have never once seen someone blatantly copy someone else's entire code library and put it in their code and then package it up as if it is their own. Tis shady.
    • Derek (Official Rep) April 12, 2014 19:19
      Hi Derek,

      We realize that the version of jQuery we're currently leveraging is older and it will likely be updated in the future, but I can't advise as to when.

      At this time I can't offer you any solutions, so I for now we hope that Fotomoto works for you as-is, but if not we certainly understand that you want to use the best-possible solution for your needs.

      Kind regards,
      Derek
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited kidding, amused, unsure, silly indifferent, undecided, unconcerned sad, anxious, confused, frustrated