
Documentation
Webflow
Code
Setup: External Scripts
External Scripts in Webflow
Make sure to always put the External Scripts before the Javascript step of the resource.
In this video you learn where to put these in your Webflow project? Or how to include a paid GSAP Club plugin in your project?
HTML
<script src="https://cdn.jsdelivr.net/npm/gsap@3.13.0/dist/gsap.min.js"></script>
Step 1: Copy structure to Webflow
Copy structure to Webflow
In the video below we described how you can copy + paste the structure of this resource to your Webflow project.
Copy to Webflow
Webflow structure is not required for this resource.
Step 1: Add HTML
HTML
<div data-loading-container="" class="loading-container">
<div class="loading-screen">
<div data-loading-words="Hello, Bonjour, स्वागत हे, Ciao, Olá, おい, Hallå, Guten tag, Hallo" class="loading-words">
<div class="loading-words__dot"></div>
<p data-loading-words-target="" class="loading-words__word">Hello</p>
</div>
</div>
</div>
HTML structure is not required for this resource.
Step 2: Add CSS
CSS
.loading-container {
z-index: 500;
pointer-events: none;
position: fixed;
inset: 0;
overflow: hidden;
}
.loading-screen {
pointer-events: auto;
color: #fff;
background-color: #000;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
display: flex;
position: absolute;
top: 0;
left: 0;
}
.loading-words {
grid-column-gap: 2em;
grid-row-gap: 2em;
align-items: center;
display: flex;
}
.loading-words__dot {
background-color: #fff;
border-radius: 50%;
width: .75em;
height: .75em;
}
.loading-words__word {
font-size: 4.5em;
font-weight: 500;
line-height: 1;
margin: 0;
}
@media screen and (max-width: 767px) {
.loading-words {
font-size: 2.75vw;
}
}
Step 2: Add custom Javascript
Custom Javascript in Webflow
In this video, Ilja gives you some guidance about using JavaScript in Webflow:
Step 2: Add Javascript
Step 3: Add Javascript
Javascript
function initWelcomingWordsLoader() {
const loadingContainer = document.querySelector('[data-loading-container]');
if (!loadingContainer) return; // Stop animation when no [data-loading-words] is found
const loadingWords = loadingContainer.querySelector('[data-loading-words]');
const wordsTarget = loadingWords.querySelector('[data-loading-words-target]');
const words = loadingWords.getAttribute('data-loading-words').split(',').map(w => w.trim());
const tl = gsap.timeline();
tl.from(loadingWords, {
opacity: 0,
yPercent: 50,
duration: 1.2,
ease: "Expo.easeInOut"
});
words.forEach(word => {
tl.call(() => {
wordsTarget.textContent = word;
}, null, '+=0.15');
});
tl.to(loadingWords, {
opacity: 0,
yPercent: -75,
duration: 0.8,
ease: "Expo.easeIn"
});
tl.to(loadingContainer, {
autoAlpha: 0,
duration: 0.6,
ease: "Power1.easeInOut"
}, "+ -0.2");
}
// Initialize Welcoming Words Loader
document.addEventListener('DOMContentLoaded', () => {
initWelcomingWordsLoader();
});
Step 3: Add custom CSS
Step 2: Add custom CSS
Custom CSS in Webflow
Curious about where to put custom CSS in Webflow? Ilja explains it in the below video:
CSS
// Hiding the Loading Container only in Webflow
:is(.wf-design-mode, .w-editor) .loading-container {
display: none;
}
Implementation
Loading Container
Use the [data-loading-container]
attribute to indicate which element should act as the loader. The script will use this as the main wrapper for the loading animation.
Loading Words
Inside the [data-loading-words]
attribute you can list as many words or phrases as you like, separated by commas. For example: [data-loading-words="Hello, Bonjour, स्वागत हे, Olá"]
.
Loading Words Target
Include one child element marked with [data-loading-words-target]
and the script will inject each word into that element in sequence.