Skip to content

astro:page-load broken and inconsistent, breaks scripts #12858

Open
@cabaucom376

Description

Astro Info

Astro                    v5.1.1
Node                     v23.5.0
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  @astrojs/node
Integrations             astro-meta-tags

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Initially, I could only get this to reproduce on Safari as it happens almost every time (especially iOS), but inconsistently, Chrome also has the bug. Sometimes when navigating to a page for the first time, astro:page-load is not triggered. After refreshing the page or navigating away and back, it triggers twice.

Utilizing the browser’s navigation controls instead of links seems to cause this more consistently. Whenever on a page with an astro:page-load script and you utilize browser controls to go back to a previous page, it will fire off the same script again, causing unintended side effects, especially if using event listeners.

What's the expected result?

astro:page-load only triggers once and is consistent. Utilizing browser navigation controls should not interfere as well.

Link to Minimal Reproducible Example

example

Participation

  • I am willing to submit a pull request for this issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions