0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-10 22:38:53 -05:00
astro/.changeset/sharp-seas-smile.md
Matthew Phillips 188eeddd47
Execute scripts on page navigation (view transitions) (#7786)
* Execute scripts on page navigation (view transitions)

* Update .changeset/sharp-seas-smile.md

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>

---------

Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
2023-07-25 08:35:47 -04:00

539 B

astro
patch

Execute scripts when navigating to a new page.

When navigating to an new page with client-side navigation, scripts are executed (and re-executed) so that any new scripts on the incoming page are run and the DOM can be updated.

However, type=module scripts never re-execute in Astro, and will not do so in client-side routing. To support cases where you want to modify the DOM, a new astro:load event listener been added:

document.addEventListener('astro:load', () => {
  updateTheDOMSomehow();
});