I am trying to add a deferred script tag like this:
const script = document.createElement('script');
script.setAttribute('src', '/script.js');
script.setAttribute('type', 'text/javascript');
script.setAttribute('defer', true);//this is the code in question!
document.getElementsByTagName('body')[0].appendChild(script);
But I found out the result script tag will generate the defer
attribute like defer=true
instead of just defer
.
Are they same? What is the implication if I do defer=true
rather than defer
?