Что лучше для сценария - document.write VS document.createElement - PullRequest
0 голосов
/ 01 апреля 2020

Я видел случаи, когда люди вызывали. js сценарии динамически, например:

async document.write(\'<script async src="https://code.jquery.com/jquery-1.12.4.min.js"><\/script>\');

и

(function(){
  var newscript = document.createElement("script"); newscript.async = true;
      newscript.src = "https://code.jquery.com/jquery-1.12.4.min.js";
  (document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(newscript);
})();

Каковы недостатки каждого из них?

...