How to Display a Random Encouragement Message in Webflow
Learn how to display a random encouragement message with automatic rotation in Webflow.
In this tutorial, Sandro, cofounder of Gemeos Webflow agency, shows you how to display a random encouragement message when the page loads in Webflow, with automatic rotation.
Example
Random message — changes every 8 seconds
| Parameter | Value | Description |
|---|---|---|
| messages | Array of objects | List of messages and emojis |
| Rotation | 8000ms | Changes every 8 seconds |
| Transition | opacity 0.4s | Fade between messages |
| Target ID | encouragement-msg | Div that receives the message |
1. Create the container in Webflow
Create a Div with the ID encouragement-msg wherever you want it: 404 page, loading page, article header, footer... The script injects the message and emoji directly.
2. Customize the messages
Update the messages array with your own quotes, brand values, tips, or welcome messages. Each object has two properties: text (the quote) and emoji (the icon).
3. Add the script in Footer code
(function() {
var messages = [
{ text: 'Build something you’ll be proud of.', emoji: '🚀' },
{ text: 'Every great website started with a single page.', emoji: '✨' },
{ text: "The best time to launch was yesterday. The second best time is now.", emoji: '⚡' },
{ text: "Good design is when you don't notice it.", emoji: '🎨' },
{ text: "Perfection is the enemy of good. Publish, iterate.", emoji: '🎯' },
{ text: 'Your visitors don’t read — they scan. Make it easy.', emoji: '👀' },
{ text: 'Speed is a feature. Every second counts.', emoji: '⚡' },
{ text: "The best CTA is the one the user notices.", emoji: '🎯' },
];
var el = document.getElementById('encouragement-msg');
if (!el) return;
function render(msg) {
el.innerHTML = '' + msg.emoji + '' +
'"' + msg.text + '"
';
}
render(messages[Math.floor(Math.random() * messages.length)]);
setInterval(function() {
var newMsg = messages[Math.floor(Math.random() * messages.length)];
el.style.opacity = '0';
el.style.transition = 'opacity 0.4s';
setTimeout(function() {
render(newMsg);
el.style.opacity = '1';
}, 400);
}, 8000);
})();Conclusion
A random encouragement message adds personality to your website. Use cases:
- 404 pages to soften the error
- Dashboard or member area pages
- Loading or maintenance screens
Lorem ipsum
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.






.avif)





