CSS Property Access By Name

JavaScript performance comparison

Revision 2 of this test case created

Info

Test how the performance of accessing CSS property by name from a CSSStyleDeclaration.

Preparation code

<div id="target"></div>
<script>
Benchmark.prototype.setup = function() {
    var target = document.getElementById('target');
    var targetStyle = target.style;
    var result;
};
</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
lowercaseCSSPropertyName
result = targetStyle.color;
result = targetStyle.position;
result = targetStyle.display;
result = targetStyle.opacity;
pending…
varyingCaseCSSPropertyName
result = targetStyle.backgroundColor;
result = targetStyle.whiteSpace;
result = targetStyle.fontSize;
result = targetStyle.textIndent;
pending…
prefixedCSSPropertyName
result = targetStyle.cssColor;
result = targetStyle.cssPosition;
result = targetStyle.cssDisplay;
result = targetStyle.cssOpacity;
pending…
prefixedCSSPropertyName worst case
result = targetStyle.epubColor;
result = targetStyle.epubPosition;
result = targetStyle.epubDisplay;
result = targetStyle.epubOpacity;
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