
Show HN: Fast DOM manipulation with jQuery-like syntax - bndr
https://github.com/bndr/fasterDOM.js
======
MattBearman
This is very cool, great work! Although I think you should make it clear in
the read me that it only supports 2 basic jQuery-like selectors (by id '#id'
and by class '.class'), ie: none of the following will work - 'div',
'[name="test"]', '.class1.class2', '.class1 .class2', 'div.class .class2[data-
test="thing"] > em#id:last-child' - I realise that last one should never be
used in real life.

Some of these could be implemented with things like getElementsByTagName,
getElementsByAttribute, and recursive calling when spaces are found. I may
even do a pull request with these if I find time this weekend :)

Have you looked into using querySelectorAll? I'd be interested to know if it's
slower and by how much.

~~~
bndr
The reason why I left only the ID and Class selectors is because they are the
fastest.

Here are some test cases: [http://jsperf.com/getelementsbyclassname-vs-
queryselectorall...](http://jsperf.com/getelementsbyclassname-vs-
queryselectorall/35)

------
hayksaakian
That's only half the puzzle though, does this solution work in most browsers?

At least as many as jQuery 2.X?

Up to as many as jQuery 1.9.Y?

~~~
bndr
Hi! Thanks for your comment! I will check and update the README with supported
browsers.

------
geuis
I looked at this the other day. While I think the effort is always good, a
library like Sizzle already handles stuff like this and a lot, lot more. Its
field tested and battle hardened. Its optimized for the 99% use cases, etc.

~~~
bndr
The idea behind this project, was to make it as small as possible and as fast
as possible. Yes it does indeed lose many features that jQuery (or Sizzle)
provide, but if you need something simple and fast, then I don't see why you
should include another 50KB file.

I really like jQuery, but sometimes its feature-rich architecture is just
slow.

~~~
riffraff
how's the comparison to e.g. zepto.js core ?

~~~
bndr
I actually did not test it against zepto.js. I will add some more tests in the
future.

------
electrichead
Nitpick: line 57 has a typo in 'undefined'. I will have a deeper look at the
code tomorrow. A 30% increase is definitely interesting.

~~~
bndr
Thanks for the tip! Fixed it.

------
bazillion
Would definitely like to use this -- could you please provide a license file?

~~~
bndr
Added the license file

------
itsbits
problem is when u start adding features, u may again end-up with equal
performances...Jquery community also takes care of performance but before that
compatibility is first preference..

------
ChrisAntaki
It looks cool! Adding a `remove` method would make it even better.

~~~
bndr
Hi! I added remove.

------
mcmire
Cool. What's the use case?

