What is the Polarion Velocity starting point event for JavaScript code?

We want to render an external app that needs the encoded project id as a query parameter and tried the following

#set( $projectId = $page.fields.project.projectId() )
 
<iframe 
 id="app-container"
    frameborder="0" 
    style="height:100vh; 
    width: 100vw;">
</iframe>
 
<script>
    document.addEventListener("DOMContentLoaded", function() {
        const encodedProjectId = encodeURIComponent($projectId);
        const iframe = document.getElementById("app-container");
        iframe.src = `/external-app?project-id=${encodedProjectId}`;
    });
</script>

Unfortunately this doesn’t work because the “DOMContentLoaded” event never triggers. What is the mount-hook for JavaScript code inside Velocity code?