D
David Mark
It's possible that when some folks are requesting information on
"JavaScript libraries", you hear "general purpose framework", when in
fact they simply mean JavaScript code that may be reused such as
"lightweight and interchangeable functions". If so, communication may
be difficult.
Just to clear up any further confusion, the unqualified term
"Javascript library" has no real meaning, other than it is a blob of
Javascript. Qualify it with "general purpose" and the connotation is
that it abstracts basic browser scripting tasks (e.g. DOM
manipulation, event handling.) Add "third-party" to it (which is what
we normally discuss here) and it becomes synonymous with garbage.
Frameworks are just libraries with lots of added bloat (so they are
even less appropriate for scripting Web pages.)
Libraries are typically designed and tested as a unit and often cannot
be deconstructed to leverage their parts. One of the most egregious
3rd-party examples (which was inexplicably popular at one time) of
this is Prototype. Back when it came out, lots of sites added 150K
(or so) of tangled up and highly inefficient script to their sites to
leverage one special effect. No good.
Then there was this ridiculous race to "pave over" every known browser
quirk. Of course, this is asking scripts to do the impossible. Did
the authors stop to consider their foolishness? No, they resorted to
user agent based browser sniffing. This is obviously inappropriate
for Web pages.
Did you ever wonder why these libraries are written almost exclusively
by people new to the language? Big surprise, they didn't know what
they were doing. And now that lots of clueless Web developers have
parked these things on their sites, they can't tear them down and
rewrite them.
The alternative, as recommended here repeatedly, is to concentrate on
writing re-usable functions. For example, a wrapper for gEBI could be
anywhere from one to a dozen lines, depending on compatibility
requirements and the competence of those writing the markup (ideally
that is also the person writing the scripts.) So start with the
obvious one (one line that calls the host method) and build more
robust versions as needed. Then do gEBTN. At that point, you will
(hopefully) have learned something about the language, DOM, etc. and
will understand exactly when to use which versions of the functions
(and where to look if something goes wrong.)
The popular trend of dumping 50-100K (at least) of ridiculously
generalized CSS selector code from unreliable sources onto a site to
"simplify" the retrieval of DOM elements is the last resort of the
lost. Most pages should be under 50K as dial-up is still very much in
use. So, as a browser scripting professional, should you use up all
of that at the design stage, on a script that you don't even
understand? Furthermore, should you exclude users who use something
other than a handful of modern browsers in their default
configurations? Ask this of virtually any "library jockey" and they
will reply with something like "Jquery Rules dude!" Hell, I asked
similar questions of the jQuery author, including lots of pointers on
how to fix his mangled and ill-conceived code and the response was
similar.