Grow your CSS skills. Land your dream job.

Poll Results: Multiple JavaScript Libraries

Published by Chris Coyier

The question was:

Do you ever use two JavaScript libraries on the same page?

My thinking in creating this poll was around two ideas:

  1. An excuse to educate people that using multiple libraries on the same page is generally a bad idea and not necessary.
  2. Uncover interesting scenarios where using multiple libraries on the same page was useful/required.

I was specifically talking about the big libraries that are general-purpose helper libraries for making working with JavaScript easier: jQuery, MooTools, Dojo, Prototype, etc. These have DOM manipulation tools, selector engines, AJAX helpers, etc. I think this is what most people think of when thinking "library." It is in using multiple of these libraries that is generally frowned upon and deemed unnecessary. Besides the fact that it's extra bandwidth and can cause conflicts if not managed properly, these libraries do many of the same things and there is little benefit to a bunch of duplicate functionality.

Here are the results:

If you see this, your browser may not support SVG, or a content aggregator may have stripped the object element.

It's no surprise that "No" came out on top, with 60% of the vote, but 60% isn't the overwhelming majority I would have guessed we would get. A full 40% said that yes, they have used multiple JavaScript libraries on the same page. Even with 27% saying yes without feeling guilty about it, I don't think we had any compelling comments detailing a use case where that made sense. Which may have been because...

As usual, a flaw in the poll

The problem with this poll is that "JavaScript Library" wasn't defined well enough. As I said above, what I meant by libraries in this poll was the general purpose libraries, but "library" can mean many more things. Twitter's @anywhere is a JavaScript library, Modernizr is a JavaScript library, Raphaƫl is a JavaScript library. There is no problem at all with using these in conjunction with a general purpose library, so in this case using multiple libraries is no big deal at all. I'm sure this is what many folks had in mind when they voted for using multiple libraries.

Final Thoughts

If you have any final thoughts on the matter, say your peace. New poll this week sometime.


  1. bill
    Permalink to comment#

    I’ve heard the term JavaScript framework used interchangeably with JavaScript library. Are they the same thing?

    • Permalink to comment#

      In my opinion “jQuery, Mootools, Prototype, etc” are frameworks and “Modernizer, @nywhere API, etc” are library’s

    • Harry
      Permalink to comment#

      Yep that’s the actual “flaw” here… guy doesn’t know the difference between a js library and a js framework…? Come on :/

    • I’d vote for that too if it was up to me.

      @Harry – don’t blame me:

  2. Abdul
    Permalink to comment#

    I’ve used multiple libraries (or frameworks) when client has specifically wanted me to use a plug-in which is written in other than jquery… because everything I write on my own I do with jquery… felt guilty afterwards :)

  3. mrtom
    Permalink to comment#

    A good JS library or framework won’t mess around with the global scope or native objects prototypes, so compatibility issues shouldn’t be a concern. Dojo, for example, has explicit support to allow you to use multiple version of itself on a single page!

    Why? Because sometimes in big projects where the development spans many developers over many years it becomes necessary to do things this way. It’s not ideal, but real life!

  4. Dragosh
    Permalink to comment#

    Here’s a use case for you:

    I want dead-easy DOM manipulation so I go with jQuery, but I also want a proper way to represent internal data, and because JavaScript OOP is a little iffy, I go with Prototype (or mootools – personally I use Prototype) for good intuitive OOP simulation.

    And of course I want it dead-fast so that’s why I go with js APIs/libraries (not frameworks in my opinion).

    Of course, this is just for HUGE projects, I did it just twice in 4 years.

    And regarding Prototype’s habit of changing natives, well that’s just something that your project needs no live with. It’s for the best anyway.

  5. I thought you meant like this :

    but i guess i was wrong too. because they are jQuery. so i really never knew what you meant. i put no because i thought you meant like using them for Different actions like if you were to have one for a jQuery slideshow but one that you didn’t make. i dont know im completely oblivious, still.

  6. I used to face this problem quite a lot in one of my projects. We were working on rails, so we had already used a lot of rails ajax helpers that generated prototype code. Later we needed to use some jQuery plugins and that would cause conflicts with prototype.

    We got the two working together, but I really hated having both frameworks running together. Luckily, we found a prototype plugin that had the same functionality and switched to it.

    IMHO, using multiple frameworks is a terrible idea. Most javascript frameworks give you enough power not to need anything else.

  7. Eamonn
    Permalink to comment#

    Once I hear terms like DOM, Native Object Prototypes, and what have you, my eyes glaze over. I never sat down and actually looked at how stuff works beyond HTML, PHP, and CSS, so I literally have no idea what any of these terms mean. It’s on the cards for the Christmas break. I just know ‘do this = this happens’. Monkey see, monkey do.

  8. Maybe the next poll should be library or framework? haha

    • No kiddin’ eh?

      This is what they call themselves:

      jQuery = Library
      YUI = Library
      ExtJS = Library

      MooTools = Framework
      Prototype = Framework

      Dojo = Toolkit

    • Permalink to comment#

      I thought they were all the same thing. You learn something knew every day I guess.

      Criss, maybe it’s time to do a post explaining the difference between each type and when to (and not to) use them since many of us mis-understand the terms. :)

    • MooTools does a lot more than jQuery… jQuery really only focuses on DOM stuff. See Some people would consider jQuery a “library” just because of that.

    • Frameworks offer a lot more functionality on top of their underlying libraries, such as ready-made accordion menus, modal dialogs, image enlargers, etc. Therefore a framework can typically be seen as a large collection of plugins in one nice package. That’s why MooTools is a lot more functional than jQuery – because in jQuery, you still need to program all the fancy stuff on top.

      jQuery does have it’s own framework though – it’s called jQuery UI :-) I tend not to use it though because it’s a lot of overhead when all you need is a couple of small plugins.

      Also, I would regard Prototype as a library, whereas its respected framework would be Scriptaculous.

      Then again, I’m probably wrong in my definitions compared to other peoples opinions.

  9. Shane Keene
    Permalink to comment#

    It really isn’t a case of not knowing the difference between a framework and a library. More a question of semantics. As Chris just posted, they all have their own ideas about what they really are. To me “library” feels more correct than “framework”. When I see the word “framework”, I tend to think of something that defines an architectural structure such as Rails or CakePHP. The major javascript libraries are really just that: libraries containing collections of tools that facilitate easier use of javascript. They don’t define (or even recommend) any particular structure or “framework”.

    • Permalink to comment#

      Actually, in the case of YUI3, YUI is definitely a “framework” in the sense that it provides an incredibly rich structure and architectural pattern for complex applications.

      I believe ExtJS and Dojo can also be considered frameworks in that regard.

  10. We try to limit our projects to one library like the poll results, and find that jQuery has most bases covered, Love jQuery! LT

  11. Its a great sharing about this multiple java script about poll results..Its very useful.Thanks for sharing

  12. Interesting question, it’s been an issue with my development as of late. In a nutshell, the only time it’s been an issue, is with WordPress (plugins galore). You just can’t ever the same version to run more than once, your bound to get into trouble. If you are in a pinch, Google “JQuery NoConflict” and be ashamed of your workaround.

  13. I personally try to keep it to a limit of one, but that is just me :D

  14. klavdij
    Permalink to comment#

    again it depends what you’re working on and what’s your budget … if the page is high budget then the answer is NO, but if i’m making a low budget page then i usualy use existing joomla modules/plugins/… without caring what library they use

    still if I can, i try to limit myself to jQuery and maybe MooTools. Also I usualy check if speed will be the ranking factor (competition wise).

    As always it depends on what you want to do, how much time you put into it and how much u get paid for it :)

  15. Don’t forget the human factor flaw…as in, “I do use more than one…but I don’t want to look like a moron.” Great poll though Chris. Thanks for sharing.

  16. Permalink to comment#

    I use jQuery for all of my JavaScript needs.

  17. to be honest the only one i’ve ever used is jQuery. I’m not really a ‘programming guy’ so I try to minimize the amount of programming (php, javascript) etc I have to do except for the essentials like building wordpress or drupal themes etc.

    that being said, I think even if i did know more than just jQuery i would still only use 1 library on a page. generally if theres a puglin thats say a Mootools plugin, 90% of the time unless its a not very widely used plugin, someone, somewhere has modified it for jQuery.

  18. I can relate this poll to server side choices. JavaScript is a language, just like PHP. And jQuery, Mootools, and Dojo, are framework, just as CakePHP or CodeIgniter. So, these libraries/frameworks are just tools to help you write easier JavaScript. And they’re all powerfull enough, there’s no need to mix’em up. IMHO, the people who uses two frameworks at the same time, are just lazy to rewrite some code to use just one framework. When you get to understand that, after all, it’s just JavaScript, things get easier. I think the problem is that people try to learn JavaScript using a framework. It’s like learning to swim using a jet-sky.

  19. Matth
    Permalink to comment#

    All of the above!
    1.) No – I avoid it whenever possible. 2.) But Yes, I do when I have to, for example when the previous developer riddled the site with Prototype-dependent functions and I want to use Jquery because I’m more comfortable with it.

    In the end, I think I have GOOD REASON to do it, but still I FEEL GUILTY about it. And thanks to Jquery’s NoConflict() declaration, everything works fine and it’s NO BIG DEAL.

    But really, 1.) No.

  20. Very useful script..nice explanation..thanks for postings

  21. Yes using multiple JS libraries is a bad idea.

This comment thread is closed. If you have important information to share, you can always contact me.

*May or may not contain any actual "CSS" or "Tricks".