4 ms·
Can you do X smaller and faster without jQuery? If X is non-trivial and you need to support old/crappy browsers, then probably not (well, not without person-ye
by gmac 14y ago
Can you do X smaller and faster without jQuery?
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 https://github.com/jawj/affogato
- masklinn 14y ago> 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.
- gmac 14y agoYou 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-widget.coffee https://github.com/jawj/github-widget/blob/master/github-wid...