Alpine.js not loading when component is the only element on the page

Sorry if this isn’t the right category, I couldn’t find the one I remember for component development discussions.

@tpbradley quick finding while testing components that load Alpine.js via the standard shared bodyEnd template (shared/assets/ + shared/templates/bodyEnd/).

If the component is the only element on the page, the shared bodyEnd script doesn’t get injected and Alpine never loads :astonished_face: . Add any other element to the page (a divider, a text block) and it works fine. :thinking:

Not an issue for me in practice, real pages always have other elements. Just wanted to flag it and ask: is this expected behavior, or is there a way to force a shared bodyEnd template to load even with a single component on the page? Couldn’t find anything on this in the docs.

Thanks! :folded_hands:

right now, at least one of the Core Components that ships with Elements needs to be on the page for Alpine to be loaded.

@ben thnaks for the fast reply

Good to know, I wasted a lot of time before I realized it. Because often, to keep my code clean, I test the components on a completely blank page. I even incorporated the library, only to realize it wasn’t needed.

thanks