View Full Version : Determining Javascript Engine

09-03-2008, 06:03 PM
With Spidermonkey --> ActionMonkey/TraceMonkey, JSCore --> Squirrelfish, IE's... improved engine (still fundamentally the same?), and whatever Opera is using (it's hard to find anything specific about it), I was wondering if anybody knows of a nice way of detecting what engine (and what version) is being used. The user-agent generally gives build ids and the verion of whatever rendering engine, but nothing (directly) about the js engine. I could always make a guess at what JS engine is being used from the user-agent, but that is less than ideal.

Any ideas?

09-03-2008, 08:27 PM
You probably need to call a number of functions which are vendor specific in order to establish browser type. for example document.all is not supported by all browsers

09-04-2008, 12:47 AM
ess: And document.all has nothing at all to do with the scripting engine.

Mozilla: I don't think Gecko has anything that tells you whether the engine used in that build is ActionMonkey, SpiderMonkey or TraceMonkey. In fact, TraceMonkey with the nanoJIT turned off is in every way and form SpiderMonkey, and that's adjustable by a pref in about:config in the TraceMonkey builds. However, we know that TraceMonkey is going to be the default enabled engine for Ff3.1 and that ActionMonkey may or may not end up being the engine for Mozilla2.0/Gecko2.0/Ff4 depending on whether they get its performance on code that is not type annoted up to the level of TraceMonkey. Though since at the moment all JavaScript on the web lacks type annotations, changing to ActionMonkey seems a lesser and lesser option as ECMA TG39 drops more and more of the features that make ActionScript fast.

Opera: It's easy for the moment: Versions < 9.50 use linear_b, versions >= 9.50 use futhark. I bet they have getting yet another engine into version 10 or 10.5 as a high priority item to meet the newly arisen competitive pressure from V8, SquirrelFish and TraceMonkey, so I would not assume futhark is staying for long unless they can gradually improve it along the way SpiderMonkey-->TraceMonkey did.
It must be a bit discouraging for the Opera devs to see, futhark is a brand new engine, when it was publicly beta released it swept past every other browser scripting engine solidly into the first place when it comes to speed. Just a few months later, both JavaScriptCore and SpiderMonkey have suddenly been optimised to double their performance and are faster, and there's all of a sudden three new engines that compete for the performance crown ahead of those two.

Microsoft: The data on script engine version is available in the ScriptEngine (http://msdn.microsoft.com/en-us/library/efy5bay1(VS.85).aspx) object. Be aware however that there are multiple different versions of both JScript 5.6 and JScript5.7. In other words, JScript 5.6 can be installed on ie<6, and for JScript5.7 there are actually two entirely separate versions of JScript with that version number, one for ie7 and one for ie<7, and the one bundled with ie7 contains many more improvements than the one for ie<7. JScript5.8 seems confined to ie8 so far, though.

WebKit: No way to differentiate between JavaScriptCore and SquirrelFish that I know of, since the latter is just an incremental rewrite of the former into a bytecoded engine.

Google: Well, if it's Chrome it's using V8.

In short: You need to use browser version sniffing to know, for those where it's at all possible to know. And Microsoft gives you the information, but is treacherous in that the same version doesn't mean the same thing in different browsers. And the Pink Invisible Unicorn be with you if you ever encounter fringe browsers!

09-04-2008, 06:58 AM
As always, good information. Thanks!

09-09-2008, 11:38 PM
jkd: As it seems, Mozilla killed the ActionMonkey project in their meeting yesterday. (I noticed because I was CCed on some bugs that Jason Orendorff mass-marked as WONTFIX.) ActionMonkey simply couldn't match the SpiderMonkey performance on code lacking type annotations, and that even before they added the nanoJIT from tamarin-tracing to SpiderMonkey in order to produce TraceMonkey. See <uri:https://wiki.mozilla.org/JavaScript:ActionMonkey> for the full rationale behind the decision.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum