views:

180

answers:

6

We started a new project and realized that we needed a general purpose javascript library that contains a nice set of string functions, MD5, base64, allows extensions, etc. Also, copying and pasting functions from other libraries doesn't sound very attractive.

So, I guess the question is which javascript library contains the most general purpose functionality out there? or maybe there is a good collection of global functions out there we could use/extend. We know DOM manipulation is covered by many AJAX libraries including JQuery.

*Mind you, we could alternatively extend ExtJS, JQuery, etc. Is that what you guys are doing?

+4  A: 

*Mind you, we could alternatively extend ExtJS, JQuery, etc. Is that what you guys are doing?

Yes, I do and I think most are. A lot of what you describe as a "general purpose library" is covered by Frameworks like JQuery, Prototype or Moo. And short of clipping the webmaster's nails, there's a JQuery plugin for everything that's not already in the core.

Still, I'm interested to see whether any other "general purpose" libraries come up here. There are fields - like string manipulation, as stated in one of the comments to another answer, and advanced date operations - where none of these frameworks is the holy grail AFAIK.

Pekka
I'm a very happy jQuery user, but does the OP's interest in "general purpose" libraries suggest dojo, mootools, or Prototype instead?
ehdv
@ehdv I'm not sure what you mean? I think it's half-way safe to say those four cover *roughly* the same field. Or are there really notable differences, fields of functionality covered by one of those three that's not covered by JQuery, or the other way round?
Pekka
My understanding of the difference between jQuery and the three I mentioned was that jQuery was written with a focus on DOM manipulation while the others were written as larger, more object-oriented frameworks. Of course, it's possible that I'm smoking crack and am completely wrong about this.
ehdv
@ehdv my general impression at least for both Prototype and Jquery that they are pretty focused on DOM manipulation, with some additional functionality. I was under the impression that Moo and Dojo strike in the same vein, but I can be wrong about that.
Pekka
A: 

I use the jQuery library and a bunch of plugins. jQuery's plugin directory contains a lot of useful tools. There's also jQuery UI, a set of interactive components and effects, which you can use if you don't want to use a more complex library like ExtJS.

Of course every project is different, and you will probably end up writing some helper functions on your own.

pako
A: 

I realize that others are going to say the same, but jQuery truly amazes me every time I learn something new about it.

DOM, CSS, and event manipulation along with easy AJAX, extensibility, and the plethora of existing extensions make jQuery a wonderful tool for web development.

Aaron
What about string manipulation?
Roatin Marth
Can you give examples of what you're missing related to string manipulation?
svinto
@svinto something that resembles format in C#, sprintf in C, basic trimming, etc. Some people would extend the string through string.prototype, others would turn them into globals, etc. A good collection of these utilities must be somewhere..If so, are they part of a nice general purpose library?
AlexanderN
@AlexanderN very true. The same goes for date operations, I think.
Pekka
@AlexanderN: I don't know about some of the more advanced string manipulation functionality, but JavaScript has some of its own: trim, split, match (for regexes). I did find a String.Format script that extends string: http://www.geekdaily.net/2007/06/21/cs-stringformat-for-javascript/
Aaron
+1  A: 

jQuery is incredibly useful for UI manipulation. However, being open source, it contains some less than optimal code. If you start running into performance issues, don't be afraid to delve into the source and see what's going on.

David Lively
However, being open source, you can address the suboptimal solution that eventually are in the code and taylor the code to your needs without have to wait for a service pack, you mean... ;)
Eineki
@Einiki "don't be afraid to delve into..." sort of implies that you *can* do so. But, yes, that's certainly a selling point.
David Lively
A: 

I have been using jQuery for some time now and that seems to handle most of the basic operations I need. It has a healthy library of plug-ins and you can always write your own. It is a very good lightweight js library and even if it doesn't do all that you need it to you it is a good starting point.

kabucey
+5  A: 

Google Closure Library

It contains (quoted from link):

a large set of reusable UI widgets and controls, and from lower-level utilities for DOM manipulation, server communication, animation, data structures, unit testing, rich-text editing, and more.

It also contains a nice set of string manipulating methods, in goog.string namespace.

Underscore

Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js

Underscore is intended to go along with other library, like jQuery or prototype. It's not extensible like jQuery or Google Closure, though.

Sagi
+1. I think this has to be the single best "all-purpose" library, steep learning curve aside.
Chetan Sastry
+1 sweet! Very interesting links.
Pekka