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:

  1. Open the Webflow Designer and click on the page where you want to trigger the script.
  2. In the right sidebar, click on the "Settings" tab.
  3. Scroll down and click on the "+" button next to the "Custom Code" section.
  4. In the "Head Code" or "Footer Code" input field, depending on where your script should be placed, add your JavaScript code.
  5. Make sure to encapsulate your script within the appropriate