title: Add defer or async attribute to dynamically generated script tags via JavaScript
body: <p>I am dynamically putting a script tag to the DOM of my page like this:</p>
  
  <pre><code>var tag = document.createElement('script');
  tag.src = "https://www.youtube.com/iframe_api";
  var firstScriptTag = document.getElementsByTagName('script')[0];
  firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
  </code></pre>
  
  <p>This should generate something like this:</p>
  
  <pre><code>&lt;script src="https://www.youtube.com/iframe_api"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I just want to put in a <code>defer</code> or <code>async</code> to this script tag like this:</p>
  
  <pre><code>&lt;script src="https://www.youtube.com/iframe_api" defer async&gt;&lt;/script&gt;
  </code></pre>
  
  <p>So how do I do this using JavaScript?</p>