mirror of
https://github.com/LalleSX/4chan-XZ.git
synced 2025-10-07 07:22:37 +02:00
Made renderContent faster
This commit is contained in:
parent
4d0253b0dd
commit
4b2b5b59af
@ -17,12 +17,20 @@ export default async function renderContent(
|
||||
|
||||
await addViteStyleTarget(shadowRoot)
|
||||
} else {
|
||||
cssPaths.forEach((cssPath: string) => {
|
||||
const fragment = document.createDocumentFragment()
|
||||
await Promise.all(
|
||||
cssPaths.map((cssPath: string) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const styleEl = document.createElement("link")
|
||||
styleEl.setAttribute("rel", "stylesheet")
|
||||
styleEl.setAttribute("href", browser.runtime.getURL(cssPath))
|
||||
shadowRoot.appendChild(styleEl)
|
||||
styleEl.onload = resolve
|
||||
styleEl.onerror = reject
|
||||
fragment.appendChild(styleEl)
|
||||
})
|
||||
})
|
||||
)
|
||||
shadowRoot.appendChild(fragment)
|
||||
}
|
||||
|
||||
shadowRoot.appendChild(appRoot)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user