可能重复:
当服务器设置 mime 类型时,为什么要写 <script type=“text/javascript”>?
我知道<script type='type/javascript'></script>
不再需要 type 属性了。我的问题是,当我自己插入脚本时,我还需要使用它吗?
var hello = document.createElement('script');
hello.type = 'text/javascript'; // still needed?
hello.async = true;
hello.src = 'http://mysite.com/script.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(hello);
我看到在 Google Analytics 中他们仍然使用它ga.type = 'text/javascript';
,Disqus 也使用它dsq.type = 'text/javascript';
那么,这有必要吗?