Skip to content

Order of stylesheet load events and script execution #4020

@emilio

Description

@emilio

First, I don't know whether there's an issue on file for this or not already.

Consider the following test-case, with a foo.css file that contains:

body { color: green }
<!DOCTYPE html>
<link rel="stylesheet" href="foo.css" onload="console.log('onload')">
<body>
<script>
  console.log("script");
  console.log(getComputedStyle(document.body).color);
</script>

Gecko will wait for the stylesheet to be loaded in order to execute the script, and thus will always log onload, then script, then rgb(0, 128, 0).

I haven't checked Edge, but Blink and WebKit both don't wait for the sheet load. What is the expected behavior here?

Just for reference, I found it because a website was relying on Gecko's behavior: rust-lang/mdBook#784

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions