From 8f3620adf051b572b1febbaa2e66650fc34a0942 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Mon, 27 Oct 2025 18:24:07 +0100 Subject: [PATCH 1/2] modules are deferred by default --- src/browser/ScriptManager.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/browser/ScriptManager.zig b/src/browser/ScriptManager.zig index b5fa3772..a63ea9fe 100644 --- a/src/browser/ScriptManager.zig +++ b/src/browser/ScriptManager.zig @@ -651,6 +651,12 @@ pub const PendingScript = struct { return &self.manager.deferreds; } + // Module scripts are deferred by default. + // https://v8.dev/features/modules#defer + if (script.kind == .module) { + return &self.manager.deferreds; + } + return &self.manager.scripts; } }; From 52fc2c365f4a34bb92b8f700bae4e033fe3bc971 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Tue, 28 Oct 2025 11:23:29 +0100 Subject: [PATCH 2/2] use getList() to pick the right queue w/ inline scripts --- src/browser/ScriptManager.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/browser/ScriptManager.zig b/src/browser/ScriptManager.zig index a63ea9fe..2788e1a5 100644 --- a/src/browser/ScriptManager.zig +++ b/src/browser/ScriptManager.zig @@ -228,9 +228,9 @@ pub fn addFromElement(self: *ScriptManager, element: *parser.Element, comptime c if (source == .@"inline") { // if we're here, it means that we have pending scripts (i.e. self.scripts // is not empty). Because the script is inline, it's complete/ready, but - // we need to process them in order + // we need to process them in order. pending_script.complete = true; - self.scripts.append(&pending_script.node); + pending_script.getList().append(&pending_script.node); return; } else { log.debug(.http, "script queue", .{