views:

1026

answers:

12

Which is the fastest javascript engine? Does it really matter?

+2  A: 

Does it matter? It probably doesn't matter - but you are the only one who could answer that for your application.

In my experience, pretty much every browser is fast enough, with the notable exception of IE6, which of course generally sucks at everything anyways.

If you look at actual benchmarks (there are many out there) it seems like Chrome, FF 3.x, and Safari are about even in terms of Javascript performance, IE8 lags just a bit behind, and IE7 quite a bit further behind (although, IMO, IE7 is still fast enough for most things).

Eric Petroelje
wonder, is any engine switcher available like user agent switcher?
rajakvk
@rajakvk - Not really, although there is "IE Tab" for Firefox as well as "Multiple IEs" that will let you easily test things in Firefox and various flavors of IE. If your Javascript works in Firefox and IE6, chances are it'll work fine in other browsers as well.
Eric Petroelje
FF is a hell of a lot slower that chrome and safari when it comes to javascript...
corymathews
+7  A: 

For production you generally don't need to care about which JavaScript engine is the fastest. Your page should work in all common browsers, period.

However, in certain projects where you are free to choose which browsers to support (such as hobby projects or projects for internal use), you'll find that the performance in different browsers varies a lot.

The two browsers I find to maintain top performance are Mozilla Firefox with its TraceMonkey engine and Google Chrome with its V8 engine. Apple Safari is also one of the fastest browsers with its Nitro engine, new in 4.0. They use new methods for "compiling" the scripts, making them perform much, much faster than before. In the future, more and more browsers will move towards this technology, as JavaScript is becoming one of the main technologies for interactive user content on the web. (I haven't mentioned Opera 10 here because I haven't personally tested it extensively, but I've heard it's faster at running JavaScript too.)

Blixt
Correct - we have to support all common browsers, so it doesn't matter which is fastest. However, developers do want **all browsers** to run javascript as quickly as possible, so when we see big speed improvements a JS engine, and that engine is open sourced for other browser teams to lean from, that's exciting.
Nathan Long
Yeah it sort of depends on how you look at the question. "Does it really matter?" could mean, "Is the JavaScript engine ever a bottleneck," or "Does it make a difference in how I write my code right now?" In terms of the bottleneck perspective - absolutely! Maybe not on a page with very little JavaScript, but with a lot, the speed of the JavaScript is directly tied to the speed of the app. In terms of the "how I write my code", probably won't matter until IE has a fast engine or has no market share. (Unless you don't need to target it for some reason.)
Russell Leggett
+1  A: 

There is a very good benchmark of two suites, the V8 Benchmark Suite v4 and the SunSpider JavaScript Benchmark available as a comparison here:

http://www.tmsnetwork.org/blog/comparison-web-browsers-javascript-benchmark-scores

In addition, Jeff Atwood wrote on his blog about Javascript performance back in 2007, most of which is still valid now:

http://www.codinghorror.com/blog/archives/001023.html

Andre Miller
+1  A: 

The speed of the JavaScript engine depends on several factors, including the code itself. Some code can be optimized for specific browsers, although developers aren't supposed to do such a thing.

Does it matter? It sure does! With the current Web 2.0 developments, where we have JavaScript doing all kinds of Ajax things, speed suddenly becomes important. Even this site uses JavaScript, even though it's just to notify me that another answer has posted while I was typing this message.

Most browsers have their own engine and they're competing very hard with one another to get the best performance. The fastest one? Undetermined since most comparisons have been a bit colored in favor of the company that sponsored the comparison.

Still, a fast engine is useless when the code is written in a bad way...

Workshop Alex
+1  A: 

It really depends on your project. If you only use minimal javascript for event handlers and a little bit of ajax/dom operations, you'll likely be fine no matter what. But if you use GWT or some other javascript heavy framework it can matter a great deal.

The direction of web applications is to do less on the server and more in the browser. The software I'm currently writing does all html generation on the client side as well as many other operations. There is a very noticeable difference between fast and slow browsers. Slower browsers still run at acceptable speeds, but chrome, safari, and ff3.5 are extremely fast and responsive. At the moment, I would say that Chrome and Safari seem to be the fastest browser for our app, but at some point it comes down to a lot more than pure js speed. Speed of DOM operation play a very large role as well.

Russell Leggett
+3  A: 

Re: "does it matter?"

The performance of Javascript engines will become increasingly important as JS is used outside of the browser. There are now many scripts and programs, testing frameworks, even server-side web application frameworks, etc, running in JS engines outside of the browser.

Many of these currently run in Mozilla's Rhino engine but I expect an increasing number to be run in V8 as performance and support for various features (as well as the ability to run scripts without a JVM like Rhino requires) becomes an issue.

Maciek
A: 

Google's V8 engine is the fastest. And it should only matter to you if you are developing something that needs to interpret Javascript.

See this answer on StackOverflow for benchmarks.

Josh Stodola
A: 

It matters to me as a web developer; many of the tools that I rely on use javascript, and just as a backend developer spends a ton of time waiting for compiles, a front end developer can end up waiting for page refreshes. A fast javascript engine helps speed this up, especially when the page is complex.

Obviously, if your application relies on javascript to be fast for your end users, you must test it on all platforms and make sure you meet rational performance targets- but a fast javascript browser (eg, chrome, opera, firefox 3.5), makes life a much more pleasant experience while in heavy development.

Tim Howland
A: 

What matters is what's the slowest (that'd be IE) in use by your users. If you can limit your user base to cover only certain browsers, you can increase the utilization of JavaScript accordingly along with it.

Esko
It is possible to ask a user to use a different browser for a specific application. Most Flash developers don't shy away from asking for a plugin.
stesch
A: 

Which is the fastest javascript engine?

V8

Does it really matter?

No

....

Well it the depends. To who? As final user, it does matter, I would rather have a browser with the fastest everything possible.

As a developer, it shouldn't unless you want to go back to the "Runs better with...." You should target the most important browsers out there.

Probably you should consider adding more detail to your question for now it is barely programming related.

OscarRyz
A: 

@uberRouse - given safety and practical concerns, a car than can do 200MPH isn't really more useful than one that can only do 100. But a twofold increase in JS speed makes web apps feasible that weren't before.

Nathan Long
@Nathan Don't know what you are talking about but a 200MPH car can certainly be more useful than a 100MPH one (in the same way as ur JS example)...it increases your radius of "easy reach" by a factor of two...so for example the job that you were reluctant to take just because of the 2 hour drive now becomes *feasible*. (Assuming of-course we are not breaking any laws by driving at 200MPH)
SDX2000
@SDX2000 - don't know what I was talking about either. :)
Nathan Long
+1  A: 

Remember that not all Javascript runs in browsers.

For example, if you're running CouchDB, views are implemented as Javascript functions.

Apache Sling allows server side scripting in Javascript.

I'm aware of BPM tools that use Javascript to write model steps.

Wikipedia lists many more server side java applications.

In these environments, where the Javascript engine is under your control, and not something in your user's browser, then certainly you'd be interested in performance.

On the other hand, many of these are tightly coupled to a specific Javascript implementation. It doesn't appear as if you could easily (for example) swap out SpiderMonkey for V8 in CouchDB.

slim