Multiple vs Singular Delimited Data Attributes

JavaScript performance comparison

Test case created by Josh Dean

Preparation code

<a href="#" class="trackevent" data-category="Video" data-action="Play" data-label="Name" data-value="SALT">Track Event</a>
<a href="#" data-trackevent="Video;;Play;;Name;;SALT">Track Event</a>
<script src=""></script>

Preparation code output

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Multiple Attributes
var $this = jQuery('a.trackevent');
var category = $'category');
var action = $'action');
var label = $'label');
var value = $'value');
Single Delimited Attribute
var $this = jQuery('[data-trackevent]');
var data = $'trackevent').split(';;');
var category = data[0];
var action = data[0];
var label = data[0];
var value = data[0];

Compare results of other browsers


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:


Comment form temporarily disabled.

Add a comment