mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-18 18:08:10 +00:00
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.
33 lines
1005 B
HTML
33 lines
1005 B
HTML
<!DOCTYPE html>
|
|
|
|
<script src="../../testing.js"></script>
|
|
|
|
<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('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>
|