Hugo Alpha: Zu welchem Zeitpunkt werden Dateien genau geladen? (am Bsp. Bilder)

Beitrag lesen

Hey Rolf,

Danke für deine Ausführungen.

Hab weiter zum Thema decode recherchiert - und bin auf diesen sehr hilfreichen Artikel gestoßen.

Sowohl load als auch decode scheinen die Bilder schon vor append zu laden, load blockiert dabei allerdings den Main Thread, weil die Bilder erst dekodiert werden müssen.

When loading an image with JavaScript in the way we actually do, the image.onload handler guarantees that trying to use the image is going to work. At this time the image is not decoded. With the first time using the image data we usually get a delay to decoding overhead. So after inserting an image into the DOM a paint event occurs and this causes a synchronous decode of the image in the main thread. As a result the main thread is blocked.