attr('style') vs css()

Benchmark created by jordan boesch on


Preparation HTML

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

Test runner

Ready to run.

Testing in
TestOps/sec
attr('style')
$('div').attr('style', 'position:relative;top:0;left:0;color:red;font-size:12px');
ready
css()
$('div').css({
 position: 'relative',
 top: 0,
 left: 0,
 color: 'red',
 fontSize: '12px'
});
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.