How do I correctly set a <span id="goog_1259993572547"></span><a href="http://dev.w3.org/html5/spec/Overview.html#boolean-attributes">boolean attribut<span id="goog_1259993572548"></span>e</a> on a DOM element object in Javascript?<div>
<br></div><div>var script = document.createElement('script');</div><div><ol><li>script.async = true; // makes the most sense, but appears go against the spec</li><li>script.async = 'true'; // worse, but not bad, but also appears to go against the spec</li>
<li>script.async = ''; // sets to empty string, but what does that really mean?</li><li>script.async = 'async'; // sets async = async, which is weird <i>and</i> verbose</li></ol><div>And then you have the debate on setting the property directly versus using setAttribute. Any thoughts on that?</div>
<div><br></div><div><br></div><div>To me, boolean attributes seem to break the <a href="http://en.wikipedia.org/wiki/Principle_of_least_astonishment">rule of least surprise</a>. I find it very hard to believe people will understand:</div>
<div><script async="" src="..."></script> or <script async="async" src="..."></script></div><div><br></div><div>more than:</div><div><script async="true" src="..."></script></div>
<div><br></div><div>Thanks,</div><div> Brian</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>