<script>
在 HEAD 本身完全加载之前,我可以在 HEAD 中附加一个元素吗?
例子:
<head>
<script src="my.js">
//etc
里面my.js
有:
var thescript = document.createElement('script');
thescript.setAttribute('type','text/javascript');
thescript.setAttribute('src','otherfile.js');
document.getElementsByTagName('head')[0].appendChild(thescript);
此代码将在浏览器到达之前执行</head>
这是安全的还是可能导致问题?我想这样做是因为我想从我的 .js 脚本中加载 jquery,所以我不必编辑我的页面来<script>
手动添加另一个
非常感谢