4 ms·
Actually since forever, you don't need to use document.getElementById("x") in any case. You just by putting the id to the element, it is already available to yo
by jbeja 12y ago
Actually since forever, you don't need to use document.getElementById("x") in any case. You just by putting the id to the element, it is already available to you referencing it by such id.
So this:
document.getElementById('foo').className =
document.getElementById('foo').className.replace(/^bold$/, '');
Can become to this:
foo.classList.remove("x");
And is miles away more performant than slow jQuery.
- dmethvin 12y agoThat won't work on Android 2.x, which doesn't support `.classList`. Performance isn't even an issue here since changing classes will cause a reapply-styles and layout.
- jbeja 12y agoI care as much for Android 2.x as ie below 10.
- mikeryan 12y agoNote the Jquery ticket for this issue can be tracked link below. In most cases Jquery will try to use to native implementations this is the ticket in this case they've never found it to be "miles away more performant". http://bugs.jquery.com/ticket/5087 http://bugs.jquery.com/ticket/5087