6 ms·
Show HN: Fast DOM manipulation with jQuery-like syntax
- hayksaakian 13y agoThat'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 13y agoHi! Thanks for your comment! I will check and update the README with supported browsers.
- electrichead 13y agoNitpick: line 57 has a typo in 'undefined'. I will have a deeper look at the code tomorrow. A 30% increase is definitely interesting.
- bndr 13y agoThanks for the tip! Fixed it.
- mcmire 13y agoCool. What's the use case?
- MattBearman 13y agoThis 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 13y agoThe 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/35 http://jsperf.com/getelementsbyclassname-vs-queryselectorall...
- geuis 13y agoI 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 13y agoThe 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.
- itsbits 13y agoproblem 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..
- bazillion 13y agoWould definitely like to use this -- could you please provide a license file?
- bndr 13y agoAdded the license file
- ChrisAntaki 13y agoIt looks cool! Adding a `remove` method would make it even better.
- bndr 13y agoHi! I added remove.
- deleted 13y ago[deleted]