Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on:load doesnt fire for <link> tags #11933

Closed
sacrosanctic opened this issue Mar 5, 2024 · 2 comments
Closed

on:load doesnt fire for <link> tags #11933

sacrosanctic opened this issue Mar 5, 2024 · 2 comments
Labels
feature request New feature or request

Comments

@sacrosanctic
Copy link
Contributor

Describe the bug

<svelte:head>
  <link
    as="image"
    href="https://upload.wikimedia.org/wikipedia/commons/4/47/American_Eskimo_Dog.jpg"
    rel="preload"
    on:load={() =>console.log('load success')}
  />
</svelte:head>

Specifically, on:load doesn't fire if asset is cached and it is an initial page load

Reproduction

https://www.sveltelab.dev/moq3nxlwmcxis9k?files=.%2Fsrc%2Froutes%2Flist%2F%2Bpage.svelte

download the repo from above and run it locally, sveltelab doesn't show the problem

navigate to /list
append a random searchparam like ?a to the img URLs to clear cache
press the browser refresh button
it say success 2 failure 1
press the browser refresh button again
it say success 0 failure 1

Logs

No response

System Info

.

Severity

annoyance

Additional Information

No response

@dummdidumm
Copy link
Member

Related to sveltejs/svelte#8301 - if we want to support this there needs to a replay mechanism for these events. I'm not sure yet if it's enough to have these in Svelte itself, or they need to be part of SvelteKit in a blocking script tag (to ensure they run), or both (Svelte providing the mechanism APIs, and SvelteKit wiring it up correctly).

@sacrosanctic
Copy link
Contributor Author

@dummdidumm should this be closed since it looks like this is fixed in svelte 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants