10 Commits

Author SHA1 Message Date
Pierre Tachoire
cc83d85542 Merge pull request #1188 from lightpanda-io/script-load-order
Some checks are pending
e2e-test / zig build release (push) Waiting to run
e2e-test / demo-scripts (push) Blocked by required conditions
e2e-test / cdp-and-hyperfine-bench (push) Blocked by required conditions
e2e-test / perf-fmt (push) Blocked by required conditions
zig-test / zig build dev (push) Waiting to run
zig-test / browser fetch (push) Blocked by required conditions
zig-test / zig test (push) Waiting to run
zig-test / perf-fmt (push) Blocked by required conditions
add a test for script load order
2025-10-28 14:12:31 +01:00
Pierre Tachoire
706a87a458 keep consistent queue for inline 2025-10-28 13:12:18 +01:00
Pierre Tachoire
3ec15ad1f7 add a test for script load order 2025-10-28 13:12:18 +01:00
Karl Seguin
07e603ecda Merge pull request #1186 from lightpanda-io/defer-module
module scripts are deferred by default
2025-10-28 18:36:54 +08:00
Pierre Tachoire
52fc2c365f use getList() to pick the right queue w/ inline scripts 2025-10-28 11:23:29 +01:00
Pierre Tachoire
8f3620adf0 modules are deferred by default 2025-10-28 09:17:57 +01:00
Karl Seguin
f7abf0956f Merge pull request #1184 from lightpanda-io/usage-fix
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
add --log_filter_scopes usage
2025-10-28 10:07:34 +08:00
Karl Seguin
73217f7832 Merge pull request #1185 from lightpanda-io/fix-script-print-wait-analysis
fix printWaitAnalysis with queue name changes
2025-10-28 10:07:13 +08:00
Pierre Tachoire
52fb2010fc fix printWaitAnalysis with queue name changes 2025-10-27 17:50:30 +01:00
Pierre Tachoire
03ffcdb604 add --log_filter_scopes usage 2025-10-27 17:37:05 +01:00
8 changed files with 66 additions and 7 deletions

View File

@@ -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", .{
@@ -643,6 +643,18 @@ pub const PendingScript = struct {
// if async isn't known, it'll fallback to defer.
const script = &self.script;
// Module scripts are deferred by default.
// https://v8.dev/features/modules#defer
if (script.kind == .module) {
return &self.manager.deferreds;
}
// Script is not a module but inline, we ignore async/defer properties.
if (script.source == .@"inline") {
return &self.manager.scripts;
}
if (script.is_async) {
return &self.manager.asyncs;
}

View File

@@ -1350,6 +1350,7 @@ test "Browser: HTML.HtmlScriptElement" {
try testing.htmlRunner("html/script/import.html");
try testing.htmlRunner("html/script/dynamic_import.html");
try testing.htmlRunner("html/script/importmap.html");
try testing.htmlRunner("html/script/order.html");
}
test "Browser: HTML.HtmlSlotElement" {

View File

@@ -488,16 +488,16 @@ pub const Page = struct {
}
{
std.debug.print("\nprimary schedule: {d}\n", .{self.scheduler.primary.count()});
var it = self.scheduler.primary.iterator();
std.debug.print("\nhigh_priority schedule: {d}\n", .{self.scheduler.high_priority.count()});
var it = self.scheduler.high_priority.iterator();
while (it.next()) |task| {
std.debug.print(" - {s} schedule: {d}ms\n", .{ task.name, task.ms - now });
}
}
{
std.debug.print("\nsecondary schedule: {d}\n", .{self.scheduler.secondary.count()});
var it = self.scheduler.secondary.iterator();
std.debug.print("\nlow_priority schedule: {d}\n", .{self.scheduler.low_priority.count()});
var it = self.scheduler.low_priority.iterator();
while (it.next()) |task| {
std.debug.print(" - {s} schedule: {d}ms\n", .{ task.name, task.ms - now });
}

View File

@@ -373,7 +373,11 @@ const Command = struct {
\\ Defaults to
++ (if (builtin.mode == .Debug) " pretty." else " logfmt.") ++
\\
\\ --user_agent_suffix
\\--log_filter_scopes
\\ Filter out too verbose logs per scope:
\\ http, unknown_prop, script_event, ...
\\
\\--user_agent_suffix
\\ Suffix to append to the Lightpanda/X.Y User-Agent
\\
;

View File

@@ -0,0 +1,35 @@
<!DOCTYPE html>
<script src="../../testing.js"></script>
<script defer id="remote_defer" src="order_defer.js"></script>
<script defer id="remote_async" src="order_async.js"></script>
<script type=module id="inline_module">
// inline module is always deferred.
list += 'g';
testing.expectEqual('abcdefg', list);
</script>
<script>
var list = '';
</script>
<script id="remote" src="order.js"></script>
<script async id="inline_async">
// inline script ignore async
list += 'b';
testing.expectEqual('ab', list);
</script>
<script defer id="inline_defer">
// inline script ignore defer
list += 'c';
testing.expectEqual('abc', list);
</script>
<script id="default">
// simple inline script
list += 'd';
testing.expectEqual('abcd', list);
</script>

View File

@@ -0,0 +1,2 @@
list += 'a';
testing.expectEqual('a', list);

View File

@@ -0,0 +1,3 @@
list += 'f';
testing.expectEqual('abcdef', list);

View File

@@ -0,0 +1,2 @@
list += 'e';
testing.expectEqual('abcde', list);