afonsoalban
6/16/2016 - 2:49 AM

Add script element to DOM with attributes.

Add script element to DOM with attributes.

function addScript(path) {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = path;
  script.id = 'dropboxjs';
  
  // se tiver parametros data
  script.dataset = {}
  script.dataset.appKey = 'etmmuj573pgwppq'; // vai se transformar em data-app-key
  
  document.getElementsByTagName("head")[0].appendChild(script);
}