File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply 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: 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: 56215
    
  13

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: 56215
    
  13

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
    
    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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: javascript performance discussion wanted
 
Similar Threads
Not checking the other conditions
validation for the fileds whose names are dynamically generated.
Closing browser
communication between servlets & JSPs
Need HTML And Javascript Code