Add

Lorem ipsum

Lorem ipsum

A
A
A
Easter egg

0 views

3 min

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

ParameterValueDescription
messagesArray of objectsList of messages and emojis
Rotation8000msChanges every 8 seconds
Transitionopacity 0.4sFade between messages
Target IDencouragement-msgDiv 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);
})();

good to know

For different messages depending on the page, use window.location.pathname to filter the array: var messages = allMessages.filter(function(m) { return m.pages.includes('home') || !m.pages; }). You can also load the messages from your Webflow CMS via a fetch to the Collections API.

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

Good to know

Heading

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.

Lorem ipsum dolor sit amet consectetur.

Lorem ipsum dolor sit amet consectetur. Aliquam orci sagittis dignissim sapien praesent donec.

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.

Published on

You might be interested in these tutorials

Similar tutorials

SEO / GEO

5 min read

5 views

How to Set Up a Redirect in Webflow? (2026)

Updated on 19.12.2025 by Sandro DA SILVA

SEO / GEO

5 min read

5 views

Add structured data to your Webflow site?

Updated on 21.08.2025 by Sandro DA SILVA

No-code

5 min read

5 views

How to Obfuscate a Link in Webflow

Updated on 23.04.2025 by Sandro DA SILVA

Let’s f*****G GO !!

Ready to launch
Your business?

Alexandre

Max

Enora

Bryan

Cannelle

Tiphaine

You'll :heart: our collaboration...