Skip to content

Support for live preview hot reload - #268

Merged
freekmurze merged 1 commit into
spatie:mainfrom
heidkaemper:feature/live-preview-hot-reload
Apr 27, 2026
Merged

Support for live preview hot reload#268
freekmurze merged 1 commit into
spatie:mainfrom
heidkaemper:feature/live-preview-hot-reload

Conversation

@heidkaemper

Copy link
Copy Markdown
Contributor

Since Statamic v6 the live preview supports hot reloading. Instead of reloading the iframe entirely, it morphs the DOM. This can cause problems with responsive images because the ResizeObserver is observing old DOM nodes.

This PR fixes the problem by adding a MutationObserver that watches for DOM changes. This logic is only applied when in live preview.

And in addition, I did a little cleanup:

  • Removed responsiveResizeObserver.onload (had been unused for a long time)
  • Replaced getBoundingClientRect with contentRect
  • Changed 'load' event to DOMContentLoaded which should be a bit faster

@freekmurze
freekmurze merged commit 2876763 into spatie:main Apr 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants