但在某种情况下也觉得放在头部比较好,比如一个给页面中的某个元素添加了事件的js脚本。页面出来了但是js没加载完的那段时间,用户对此元素做事件操作的时候就出不来应该有的效果。
现在比较倾向于放在头部,做一些优化的工作尽量让js加载快一点。
var xhr = new XMLHttpRequest()xhr.open("GET", window.location.pathname + window.location.search, true)
xhr.send()
xhr.onreadystatechange = function() {
if(this.readyState == this.HEADERS_RECEIVED) {
console.log(xhr.getAllResponseHeaders())
}
}
这样就行了,可以玩玩看
如果要查找单个可以用getResponseHeader