mirror of
https://github.com/ankitects/anki.git
synced 2025-12-21 10:52:57 -05:00
Start decoding images immediately (#4471)
* Start decoding images immediately * Start decoding images immediately (revised) * New contributor
This commit is contained in:
parent
62252f7216
commit
8f2144534b
2 changed files with 3 additions and 3 deletions
|
|
@ -255,6 +255,7 @@ Ranjit Odedra <ranjitodedra.dev@gmail.com>
|
|||
Eltaurus <https://github.com/Eltaurus-Lt>
|
||||
jariji
|
||||
Francisco Esteva <fr.esteva@duocuc.cl>
|
||||
SelfishPig <https://github.com/SelfishPig>
|
||||
|
||||
********************
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,6 @@ export function allImagesLoaded(): Promise<void[]> {
|
|||
}
|
||||
|
||||
function imageLoaded(img: HTMLImageElement): Promise<void> {
|
||||
if (!img.getAttribute("decoding")) {
|
||||
img.decoding = "async";
|
||||
}
|
||||
return img.complete
|
||||
? Promise.resolve()
|
||||
: new Promise((resolve) => {
|
||||
|
|
@ -31,6 +28,8 @@ function extractImageSrcs(fragment: DocumentFragment): string[] {
|
|||
function createImage(src: string): HTMLImageElement {
|
||||
const img = new Image();
|
||||
img.src = src;
|
||||
img.decoding = "async";
|
||||
img.decode();
|
||||
return img;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue