3

I have thought hard about what library would be best, but any library "X" would be missing a certain feature from library "Y".

What are peoples' thoughts on using mutliple JavaScript libraries simultaneously?

1
  • 1
    Choose libraries that play nice with each other. For example, jQuery and YUI are very self-encapsulated, whereas Prototype and Mootools aren't and so have higher chance of conflicts. Commented Sep 30, 2009 at 19:43

3 Answers 3

7

Quite simply, don't do it. You'll have headaches with:

  1. Inconsistent code in your application ($('element') vs $('#element'))
  2. Possible conflicting libraries (Date.prototype.toJSON() is often defined in libs)
  3. Additional overhead for your users to download, thus worse user experience
  4. More documentation to keep track of, thus larger learning curve for new devs
  5. More code to keep updated and secure
  6. More time spent figuring out which library you want to use for what.

If you have some specific need that a different library addresses, pull the pieces of that library as needed. It'll save you way more time than it takes to extract what you need.

Sign up to request clarification or add additional context in comments.

3 Comments

This is a poor answer and is inconsistent with today's best practices and should be revised as such.
@Robotsushi - your examples of using jQuery+backbone or something along those lines is fine - those libraries are meant to work together. That's like saying you shouldn't use jQuery plugins or something. That's not what the OP was talking about when the question was asked 3 years ago.
To address Brent, the OP is not talking about using, for example, jQuery + jQuery plugins. That's not multiple libraries. He's talking about jQuery + PrototypeJS; baseline "libraries" that provide the same functionality in different ways, but occasionally have a missing feature in one or the other.
2

With more and more javascript libraries coming out every day it is often impossible to not include multiple javascript libraries.

I frequently use any combination of the following libraries:

  • jQuery
  • KendoUI
  • backbone.js
  • knockout.js
  • require.js
  • underscore.js
  • modernizer.js

Any good javascript developer will utilize any library necessary to complete the solution.

To arbitrarily limit yourself to one library is just going to create extra work for you.

Be conscious of your memory footprint, but don't re-invent the wheel unless you need to.

Comments

1

Use jQuery and its plugins. You'll never not have the feature you need :). I don't see anything wrong with using multiple libraries, but it is nice to stay within a single framework...it makes dealing with code and managing a codebase a bit easier.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.