Running custom code before the page loads possible?

I am trying to run an api call before the page loads for user logins.

I have a database built already with members, their accounts, purchases, etc… I wanted the front end to be easier to change and edit so I moved to Webflow. Everything is fine and working as I expected except for the page loading before calling the api. This is an issue because if the user is not logged into my site they can crawl any page they want before getting kicked to the login screen. A suggestion was a page loader but that still doesn’t solve the issue.

I have Memberstack on another site and noticed that there is no delay or glitch in the page when elements are suppose to be displayed or not so Im assuming Webflow and Memberstack has worked together to run their code before the page loads.

<script type="text/javascript">
    function preloadFunc()
    {
        alert("PreLoad");
    }
    window.onpaint = preloadFunc();
</script>

helped me, just add it to the head custom code

1 Like