Re:From jQuery to JavaScript and back again
by masklinn on Friday February 08, 2013 @10:30AM
(#5188283)
> Conversely, if you can get away with targeting only IE9+, WebKit and Mozilla, or if X is dead simple, then almost certainly yes.
Faster maybe, but smaller probably not unless you rebuild half the jquery interface on top of straight DOM (and in that case, why not use zepto or some other similar library?)
Every time I try to go with straight DOM, it turns out to be a pain because the DOM interface as a swamp of javaisms unfit for human usage.
Re:From jQuery to JavaScript and back again
by gmac on Saturday February 09, 2013 @08:16AM
(#5192457)
You certainly can go smaller if your needs aren't hugely complex. I have a 'make' function for creating and appending to the DOM, 'get' for retrieving, and 'cls' for className-wrangling. See for example here (in CoffeeScript, which makes Object arguments seem terribly natural):
https://github.com/jawj/github-widget/blob/master/github-wid...
If X is non-trivial and you need to support old/crappy browsers, then probably not (well, not without person-years of pain).
Conversely, if you can get away with targeting only IE9+, WebKit and Mozilla, or if X is dead simple, then almost certainly yes. And you should try it, too, because jQuery is a big warty kitchen-sink of a framework. In those cases these days I use CoffeeScript and a few simple homegrown helpers[1].
[1] https://github.com/jawj/affogato