Thanks @baris for the code snippet. I had to modify it a bit to have it run only after the DOM is fully loaded as otherwise app.require wasn't available:
<script>
document.addEventListener("DOMContentLoaded", async () => {
if (typeof app !== 'undefined' && typeof app.require === 'function') {
const myWidget = await app.require("mywidgetmodule");
myWidget.init();
} else {
console.error("app.require is not available.");
}
});
</script>
If you have suggestions how to do it better feel free to tell me. However, my problem is solved, so thank you!