3 ms·
I'm curious - is there actually much overhead if your browser supports these native methods? Surely jQuery just goes straight to them? For anyone who knows jQ
by AndrewDucker 13y ago
I'm curious - is there actually much overhead if your browser supports these native methods? Surely jQuery just goes straight to them?
For anyone who knows jQuery internals, does it check for browser compatibility on every call, or does it check once, and then hardwire up the correct methods for the next call?
- ricardobeat 13y agojQuery has lots of feature checks, a long dependency tree, and a half-decade of accumulated bug reports and corner-cases. It also implements custom selectors and "fixes" behaviors in querySelectorAll that often leads to a significant drop in performance. Not that you'll notice unless you're using the DOM for rendering complex graphics/UI :)
- ivanca 13y agoFalse, any complex manipulation (graphic-less or not) of all DOM elements in the current page an you notice a significant performance cost in orders of magnitude.
- ghiculescu 13y agoA lot of the checks are done on initialisation. Take a look at jQuery.support - http://api.jquery.com/jQuery.support/ http://api.jquery.com/jQuery.support/ - it's around line 1300 in http://code.jquery.com/jquery-1.9.1.js http://code.jquery.com/jquery-1.9.1.js
- Schlaefer 13y agoRight from the source: "Sets document-related variables once based on the current document" [1]. It's a very readable document and the comments give good overview about quirks you have to be aware of. My personal opinion: not using jQuery (or similar library) for normal webpages is premature optimization and it will hurt more than help. [1] https://github.com/jquery/sizzle/blob/master/dist/sizzle.js#L489 https://github.com/jquery/sizzle/blob/master/dist/sizzle.js#...
- rorrr2 13y agojQuery is much much slower for many selectors, often orders of magnitude slower.