Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wanted: Minimal cross-browser Javascript library

I know some Javascript, but just realized I know very little about cross-browser issues. Nasty little things like the this object in event callbacks in IE (as in xhr.onreadystatechange = function () { ... }) not referring to the object the function is applied to, but instead to window, which is not exactly useful.

There's an impressive and comprehensive-looking list of differences here on SO.

Is there also a library that covers these nasty cross-browser issues without selling you a whole lifestyle plus round corners with slide effects? I know jQuery is great (and modular, I know, UI coming as an extra; and I bet others are great, too), but I'm looking for something lean, closer to the roots. Just doing the minimum and eliminating the nastiness. Doesn't have to wrap the DOM in sugar.

Update

Thanks everybody for your suggestions. I'm going to take a look at MyLib, microJS, Ender, and Sizzle. GWT, while certainly being cross-browser, is not, I think, a lightweight approach, but definitely an interesting one.

like image 396
Lumi Avatar asked Jan 20 '23 01:01

Lumi


2 Answers

jQuery is not modular - it's all or nothing. If you want a solid, cross browser library that you can trim to the minimum you require, it's hard to go past MyLibrary: http://www.cinsoft.net/mylib.html.

The name "MyLibrary" means that when you download and customise it, it becomes your library.

It is absolutely solid, fast and extremely modular. You can use just the bits you want and remove anything unnecessary.

BTW, many libraries like jQuery aren't really "cross browser", they are multi–browser — they have a limited set of browsers that they support and don't care much about the rest. On the other hand, MyLibrary is written to be genuinely cross–browser. It also provides excellent feature detection shortcuts so you can easily write robust code with fallback.

like image 65
RobG Avatar answered Jan 21 '23 15:01

RobG


What do you want?

Just check microJS and download the libraries you want.

As mentioned already you can use Ender to bundle them

like image 21
Raynos Avatar answered Jan 21 '23 14:01

Raynos