Parameters in HTML attributes
JavaScript performance comparison
Info
Is using attributes in html tags for js-parameters fast enough?
Preparation code
<div id="target"></div>
<div id="config" data-param1 = "Some string" data-param2="http://google.com"></div>
<script>
var myConf = {
param1: "Some string",
param2: "http://google.com"
}
</script>
<script>
Benchmark.prototype.setup = function() {
var target = document.getElementById('target');
var s1;
var s2;
};
Benchmark.prototype.teardown = function() {
target.innerHTML = s1 + ' ' + s2;
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
HTML attributes |
|
pending… |
Simple JS data |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments