nonblocking dynamic imports

Allows dynamic imports to be loading asynchronously. I know reddit isnt the
best example, since it doesn't fully load, but this reduced the load time from
~7.2s to ~4.8s.
This commit is contained in:
Karl Seguin
2025-09-24 22:25:56 +08:00
parent eff7d58f4b
commit b692c5db60
5 changed files with 342 additions and 77 deletions

View File

@@ -5,15 +5,28 @@
<script id=dynamic_import type=module>
const promise1 = new Promise((resolve) => {
Promise.all([
import('./import.js'),
import('./import.js'),
import('./import.js'),
import('./import.js'),
import('./import.js'),
import('./import.js'),
import('./import2.js'),
import('./import.js'),
import('./import.js'),
]).then(resolve);
});
testing.async(promise1, (res) => {
testing.expectEqual(9, res.length);
testing.expectEqual('hello', res[0].greeting);
testing.expectEqual('hello', res[1].greeting);
testing.expectEqual('world', res[2].greeting);
})
testing.expectEqual('hello', res[2].greeting);
testing.expectEqual('hello', res[3].greeting);
testing.expectEqual('hello', res[4].greeting);
testing.expectEqual('hello', res[5].greeting);
testing.expectEqual('world', res[6].greeting);
testing.expectEqual('hello', res[7].greeting);
testing.expectEqual('hello', res[8].greeting);
});
</script>