We've added a custom JavaScript to SharePoint 2019 on all modern pages (it's just a standard script tag, <script src="..." type="module">). It works fine except when SharePoint do a partial page load, then the script won't execute. I don't understand why or when SharePoint decide to do a full- or a partial page load, some links do, some don't. But it happens when I go from one library to another using the left navigation links (Quickstart).
Is it possible to execute my script even when the page is not fully loaded? I've experimented a bit using observers, because the changes when I go to another page obviously, and so I thought i could hooked up on that one. But with no luck.