Webflow sync, pageviews & more.
NEW

Is it possible to have a load animation only display for the user's first visit to the home page in Webflow, without being shown on subsequent visits?

TL;DR
  • Create a full-screen loader using Webflow interactions that plays on first page load.
  • Use JavaScript with localStorage to check if the user has visited before; if so, skip the animation by hiding the loader.
  • Add the script to your homepage footer and ensure fallback CSS keeps the loader visible only on the first visit.

Yes, it’s possible to show a load animation only on the user’s first visit to the homepage by using browser cookies or localStorage in Webflow.

1. Use Webflow Interactions for the Load Animation

  • Design your load animation as a full-screen element (e.g., a div block) that covers the homepage.
  • Set the animation to trigger on page load using Webflow's Page Load Interactions.
  • Make sure the animation ends with the loader element being hidden (e.g., display: none or opacity to 0 and interaction hide after animation).

2. Add Custom Code to Track Visitor's First Visit

  • You'll need custom JavaScript that checks if the user has visited before.
  • Use localStorage (preferable to cookies for client-side use) to track this.

Here’s what your inline JS script should do:

  • On page load:
  • Check if a key (e.g., 'hasVisited') exists in localStorage.
  • If yes, then immediately hide the loader element (to prevent flash/animation).
  • If no, allow the loader animation to play and set 'hasVisited' to true.

3. Where to Add the Custom Code

  • Go to Project Settings > Custom Code > Footer or use the Page Settings > Footer Code section for your homepage.
  • Add the script inside a <script> tag.

Inline example:

<script>  document.addEventListener("DOMContentLoaded", function() {    const hasVisited = localStorage.getItem("hasVisited");    if (hasVisited) {      document.querySelector("#your-loader-id").style.display = "none";    } else {      localStorage.setItem("hasVisited", "true");    }  });</script>
  • Replace #your-loader-id with the actual ID of your loader element.

4. Prevent FOUC (Flash of Unwanted Content)

  • You can add custom CSS in the <style> tag in the head to ensure the loader is hidden immediately via JS if needed.

Example fallback CSS:

<style>  #your-loader-id {    display: block;  }</style>

This ensures the loader shows by default, and the custom JS hides it on repeat visits.

Summary

You can conditionally display a homepage load animation only on the user’s first visit by combining Webflow interactions with custom JavaScript using localStorage to track visits. The animation runs once, then is skipped on all subsequent visits to improve user experience.

Rate this answer

Other Webflow Questions