Skip to content

Edge case in load order with <script defer> - TypeError: system is undefined #5228

@wmurphyrd

Description

@wmurphyrd

Description:

Pretty far on the edge, but I hit this while working on my experiments with Svelte + WebComponents for reusable A-Frame structures.

While in a script that's loaded with the defer attribute, attempting to insert new entities into the page will cause the inserted entity to attempt to load prematurely and throw errors, in this case the geometry component is initializing before the systems have been initialized.

You'll see from the logs in the reprex that document.readyState is interactive, so it passes this gate in connectedCallback and tries to load immediately, but also that the system has not yet been set so it fails.

Since defer causes a script to run before DOMContentLoaded, but apparently after the switch to interactive readyState, this seems the be sneaking into a tiny chink in the A-Frame load order.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions