How does Webflow determine when a page is finished loading and is it possible to trigger a script at the same time?
Published on
September 22, 2023
Webflow determines if a page is finished loading using an event called "window.onload". This event fires when all the resources of a page, such as images, stylesheets, and scripts, have finished downloading and the DOM (Document Object Model) is ready. However, it's important to note that certain elements, like videos or asynchronous scripts, might continue to load even after the "window.onload" event has fired.
Yes, it is possible to trigger a script at the same time as the page finishes loading in Webflow. Here's how you can do it:
- Open the Webflow Designer and click on the page where you want to trigger the script.
- In the right sidebar, click on the "Settings" tab.
- Scroll down and click on the "+" button next to the "Custom Code" section.
- In the "Head Code" or "Footer Code" input field, depending on where your script should be placed, add your JavaScript code.
- Make sure to encapsulate your script within the appropriate