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

update script behavior section #6798

Merged
merged 14 commits into from
Mar 9, 2024
Merged
Prev Previous commit
Next Next commit
add is:inline to example
  • Loading branch information
OliverSpeir authored Mar 5, 2024
commit 160473758b45d232e9054266ea01855663d6c0c3
2 changes: 1 addition & 1 deletion src/content/docs/en/guides/view-transitions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ If you have code that sets up global state in an inline script, this state will
Inline scripts can be reexecuted after every transition by adding the `data-astro-rerun` property. This will make the script `is:inline` implicitly, so it will not work for bundled scripts.
OliverSpeir marked this conversation as resolved.
Show resolved Hide resolved

```astro
<script data-astro-rerun>...</script>
<script is:inline data-astro-rerun>...</script>
```

If a script should execute every time a page is loaded, it should be executed by a [lifecycle event](#lifecycle-events). Event listeners for `DOMContentLoaded` can be replaced by the [`astro:page-load`](http://localhost:4321/en/guides/view-transitions/#astropage-load) lifecycle event.
Expand Down
Loading