frames_benchmark.html 849 Bytes
Newer Older
jatuporn Tonggasem's avatar
jatuporn Tonggasem committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
<!DOCTYPE html>
<script>
  var start;
  var dom;

  function run() {
    if (dom) {
      dom.parentNode.removeChild(dom);
    }

    dom = document.createElement('div');
    var result = document.createElement('div');
    dom.appendChild(result);
    document.body.appendChild(dom);

    start = Date.now();

    for (var i = 0; i < 100; i++) {
      var iframe = document.createElement('iframe');
      iframe.style.width = '200px';
      iframe.style.height = '30px';
      dom.appendChild(iframe);
      var content = iframe.contentWindow.document.createTextNode('hello, world');
      iframe.contentWindow.document.body.appendChild(content);
      iframe.contentWindow.document.body.style.overflow = 'hidden';
    }

    result.innerHTML = 'Done! ' + (Date.now() - start) + ' ms';
  }
</script>
<input type="button" value="Go!" onclick="run()">