Parsing json from data attrs
JavaScript performance comparison
Info
Testing performance of parsing json from data attributes
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js">
</script>
<div id="single" data-json='{"a":"a","b":"b","c":"c"}'>
</div>
<div id="double" data-json="{'a':'a','b':'b','c':'c'}">
</div>
<div id="split" data-split="a|b|c|d|e">
</div>
<script>
Benchmark.prototype.setup = function() {
var $single = $('#single'),
$double = $('#double'),
$split = $('#split')
};
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Single data |
|
pending… |
Single attr |
|
pending… |
Double attr replace |
|
pending… |
Split Data |
|
pending… |
Split Attr |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments