每过1秒实时检查是否存在对应的值

let load =(cb) =>{
    let timer
    let check = ()=>{
        if(performance.timing.loadEventEnd){
            clearTimeout(timer)
            cb()
        }else{
            timer = setTimeout(check,100)
        }
    }
    window.addEventListener('load',check,false)
}

load(()=>{
    let perfData = performance.timing
    let data = processData(perfData)
    cb(data)
})

 

posted @ 2020-06-10 22:42  TTtttt5  阅读(133)  评论(0编辑  收藏  举报