Performance Tip #3: Setting Styles

A common task to do in JavaScript is to change the appearance of elements dynamically. There’s a couple of ways of doing that: 1. Setting style properties in the DOM divTest.style.backgroundColor = "red"; divTest.style.fontWeight = "bold"; 2. Setting the style property to a CSS string divTest.style.cssText = "background-color: red; font-weight: bold; margin: 0px 0px 0px…