3 ms·
Hi there, I'm Kory. I'm not surprised to see a large amount of disagreement and anger, partly because it threw this post together pretty quickly and i probably
by korynunn 14y ago
Hi there, I'm Kory.
I'm not surprised to see a large amount of disagreement and anger, partly because it threw this post together pretty quickly and i probably didn't explain things as well as i could have, and partly because, well, a lot of people really just cant write fast web apps.
In no particular order i would like to address a few things (most of which were addressed in the article if you read to the end..):
1. I never said "don't use jQuery". What I was trying to convey was "don't use jQuery stupidly".
2. I never said the DOM was the fastest part of the platform, obviously it isn't, in fact it is one of the slowest parts. But then, I wasn't comparing its speed to the rest of the platform, but rather to human perception. It doesn't matter if DOM manipulation is orders of magnitude slower than object manipulation, because it is easily fast enough to do pretty much anything, on pretty much any device, if you know what you are doing.
3. The fact that you read hacker news is a good sign that this post wasn't aimed at you. The post was a vent from the frustration of hearing 'The DOM is slow' as an excuse by people with no idea what they are talking about. It's a belief that is just accepted by many who have had difficulties with web development in the past, without any investigation as to what the actual issue is.
One think I see people doing a LOT is DOM selection. I find the pattern poor generally. Think about the standard case for developing 'web apps'.
1. Build objects in a server that describe the application.
2. Build a massive string from said objects.
3. Send it over the intertubes.
4. Give it to a browser, which then parses said string, fixes any errors you almost certainly made, then creates DOM elements.
5. Insert said DOM elements into the document.
6. Wait untill all of this is done, then use a tree searching algorithm to find said objects using jQuery/querySelectorAll/whatever.
7. Manipulate said object.
WAT. This seems a pointlessly convoluted pattern.
Alternative:
1. Build some objects on the server that describe the application.
2. Send it over the intertubes (Which will be faster, because a description of an app is going to be smaller than every little bit of it being sent)
3. Let JavaScript create DOM directly. No parsing, just pure DOM API calls. >>>Keep a reference to important elements.<<<
4. Insert DOM into document.
5. Work directly with the DOM elements. No selecting, no string manipulation, just normal object manipulation.
I look forward to the argument that ensues.
- korynunn 14y agoAlso, for those commenting on my blog being down, yeah I would expect that to be the case, its hosted on our crappy media center, behind a home internet connection, on a PC that has about 5 IIS apps and 3 Node apps. I never really expected to have more than maybe 5 concurrent connections.