Load data in parallel with async components

Start all requests up front and hand the pending promises to your markup: everything loads at the same time, while the output order stays the same.

Components in Jeasx can be async and simply await their data. But the renderer resolves them one after another, so three components that each wait one second take three seconds in total. As JSX also accepts promises as children, starting the requests early avoids this. Switch between both modes: the bars below show when each request started and finished.

Requests

sequential

Waiting for Ada...

Ada requested at +1 ms, loaded at +1001 ms

Waiting for Grace...

Grace requested at +1002 ms, loaded at +2002 ms

Waiting for Linus...

Linus requested at +2002 ms, loaded at +3004 ms
Rendered in 3004 ms