| Author |
javascript performance discussion wanted
|
Wendy Gibbons
Bartender
Joined: Oct 21, 2008
Posts: 1098
|
|
is javascript really that slow?
At work we are just starting to write a new ExtJS front end to our app and 2 gurus are doing all of the code reviews.
They are quibbling (my opnion) that i use the wrong type of for loop as a is more efficient than a foreach loop.
are they being sensible?>
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
|
There's quite a bit of information on this if you google it. The general consensus seems to be that foreach loops are slower. And it seems to be slower/faster depending on the browser. If your app is very front-end heavy then I wouldn't consider it to be "quibbling".
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56204
|
|
Or is this just a case of premature optimization?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
Bear Bibeault wrote:Or is this just a case of premature optimization?
Quite possibly. I would just say that if you know something is slow and there is already an alternative then why use the slow one? It just becomes something you have to go back and refactor later.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56204
|
|
Perhaps but in this case I've never seen a difference in performance that has had any visible effect.
For the record I use both styles -- choosing whichever seems to fit the situation better or improve the clarity of the code.
|
 |
Wendy Gibbons
Bartender
Joined: Oct 21, 2008
Posts: 1098
|
|
Thanks guys,I have done some reading and with the newer browsers it doesn't make that much difference but as we are mainly going over arrays, it makes it easier anyway.
And our front end is very very heavy, it makes HTML look and behave like swing (but with enough differences to keep you irritated).
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
You are right that it does not make a difference anymore. Most bottlenecks come from poor design decisions and people refusing to change backends to fit the front end needs.
Eric
|
 |
 |
|
|
subject: javascript performance discussion wanted
|
|
|