Hacker News new | ask | show | jobs
by malandrew 4812 days ago
I know jQuery pretty well as I worked with it a lot until about 1-2 years ago and now I'm working on a product that achieves iOS CoreAnimation levels of performance when performing DOM manipulation. That being said, I don't think people should perform native DOM manipulation directly in any app, only via libraries and frameworks.

jQuery was great. Emphasis on the was. It's monolithic and has become long in the tooth and there are now much much better approaches to DOM manipulation that are now achievable. If you keep doing things the jQuery way you're always going to hit performance issues that cause jitter and jank in a web app. You'll never get buttery smooth, consistent 60fps performance with jQuery approaches. The biggest problems with jQuery is that it makes selecting and updating DOM elements so easy that almost no one caches their DOM pointers and that it doesn't really support performance deferrable atomic updates when performing batch updates on nodes. There are more issues than just that too. The number of layers of indirections that must be calculated through to perform even trivial updates is very wasteful, especially when you consider that many of those layers of indirection are there to support older buggy as hell browsers that only continue to lose market share.

If you want 60fps in your web app, then you need to program to 16.66ms cycles. If any of you updates take more than that, then it blocks the event loop and your FPS drops. Many many operations in jQuery are in the 100+ms territory. Your top framerate at 100ms is a mere 10fps.

When it comes to the DOM it most certainly is not premature optimization. If you think otherwise then you probably haven't built a serious web app on par with the native apps on iOS and Android. With the DOM, you need to code for performance from day 1. Like the turtles, it's abstractions all the way down and with each layer you lose some performance. The DOM is an abstraction that needs to be handled very very careful for it not to become a performance killer.