const cache = {} // 根据子应用的name来做缓存
export const parseHtml = async (entry, name) => {
if (cache[name]) {
return cache[name]
}
const html = await fetchResource(entry)
let allScript = []
const div = document.createElement('div')
div.innerHTML = html
const [dom, scriptUrl, script] = await getResources(div, entry)
const fetchedScripts = await Promise.all(scriptUrl.map(async item => fetchResource(item)))
allScript = script.concat(fetchedScripts)
cache[name] = [dom, allScript]
return [dom, allScript]
}
6-13 提高加载性能 - 应用缓存
最新推荐文章于 2024-08-29 22:17:36 发布