aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes javascript performance discussion wanted Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "javascript performance discussion wanted" Watch "javascript performance discussion wanted" New topic
Author

javascript performance discussion wanted

Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

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
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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".


GenRocket - Experts at Building Test Data
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61419
    
  67

Or is this just a case of premature optimization?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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: 61419
    
  67

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: 1107

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: 15376
    
    6
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javascript performance discussion wanted