Skip to content

Commit 07e603e

Browse files
authored
Merge pull request #1186 from lightpanda-io/defer-module
module scripts are deferred by default
2 parents f7abf09 + 52fc2c3 commit 07e603e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/browser/ScriptManager.zig

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ pub fn addFromElement(self: *ScriptManager, element: *parser.Element, comptime c
228228
if (source == .@"inline") {
229229
// if we're here, it means that we have pending scripts (i.e. self.scripts
230230
// is not empty). Because the script is inline, it's complete/ready, but
231-
// we need to process them in order
231+
// we need to process them in order.
232232
pending_script.complete = true;
233-
self.scripts.append(&pending_script.node);
233+
pending_script.getList().append(&pending_script.node);
234234
return;
235235
} else {
236236
log.debug(.http, "script queue", .{
@@ -651,6 +651,12 @@ pub const PendingScript = struct {
651651
return &self.manager.deferreds;
652652
}
653653

654+
// Module scripts are deferred by default.
655+
// https://v8.dev/features/modules#defer
656+
if (script.kind == .module) {
657+
return &self.manager.deferreds;
658+
}
659+
654660
return &self.manager.scripts;
655661
}
656662
};

0 commit comments

Comments
 (0)