3 ms·
I hate articles that just make a bunch of assertions without any explanation as to _why_ or performance tests. If I'm earning a savings of < 1ms by making one
by FlemishBeeCycle 16y ago
I hate articles that just make a bunch of assertions without any explanation as to _why_ or performance tests.
If I'm earning a savings of < 1ms by making one choice over the other, it is probably more time efficient for me to simply not worry about it.
> 8 But if you have multiple string concatenation, prefer pushing to an Array and then calling the join() method on it. This is particularly helpful while building HTML snippets.
Depends on too many factors (browser, number of segments, segment length etc) to a be rule. Most of the time, the performance between this and += is going to be more or less the same.
> 26 With AJAX, GET works faster than POST. So prefer GET unless request length is more than 2K; yes, you guessed it right - IE.
Use GET or POST when you're supposed to not based on how much information you think you'll be sending.
> 27. Go easy on scripted animations.
What's easy? What's hard?
> 30. Always fall back to core JavaScript whenever possible. Limit framework usage.
It would be more prudent to _know_ your framework, and know when to not use it. IE (even in 9!) still doesn't implement indexOf - I can roll my own solution or use jQuery's inArray.
Here's a better article http://www.slideshare.net/nzakas/speed-up-your-javascript http://www.slideshare.net/nzakas/speed-up-your-javascript
- webuiarchitect 16y agoNickolas Zakas' Slideshare presentation mainly covers the four areas of performance and goes deep into it, while my aim was to cover as many aspects as possible (not restricting it only to JavaScript) and add brief description wherever I could. Also, when we talk about performance, we usually talk about milliseconds - so if doing something shows even slightest improvement on at least one of the browser (e.g. accessing object properties by dot notation works faster on Safari and doesn't make difference on other browsers), it helps in keeping a watch on that practice. Even JSLint does the same.