setAttribute src vs attribute assign
JavaScript performance comparison
Info
imageElement.setAttribute("src", "new src") vs imageElement.src = "new src"
Preparation code
<img id="testSrcAssign" src="http://i3.ytimg.com/vi/uY-HU2Xh7PE/3.jpg">
Preparation code output

Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
src assign |
|
pending… |
setAttribute |
|
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:
- Revision 1: published by Paul Comanici (darkyndy)
- Revision 2: published by Paul Comanici (darkyndy)
0 comments