Script v Eval

JavaScript performance comparison

Test case created by peter

Info

Checking to see if eval is faster or <script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Eval
eval('for (var i = 0 ; i<10000;i++){var x = 100; var y = 200;}');
pending…
Script
var myScript = document.createElement('script');
myScript.setAttribute('type', 'text/javascript');
myScript.innerHTML = 'for (var i = 0 ; i<10000;i++){var x = 100; var y = 200;}';
document.body.appendChild(myScript);
pending…
Complex Eval
eval('for (var i = 0 ; i<1000;i++){var x = 2000; var y = 200;}');
pending…
Complex script
var myScript = document.createElement('script');
myScript.setAttribute('type', 'text/javascript');
myScript.innerHTML = 'for (var i = 0 ; i<20000;i++){var x = 100; var y = 200;}';
document.body.appendChild(myScript);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment