Easter egg3 min read
How to Play a Level-Up Sound at the End of an Article in Webflow
Learn how to play a level-up sound when a visitor finishes reading a Webflow article with the Web Audio API.
In this tutorial, Sandro, cofounder of Gemeos Webflow agency, shows you how to play a level-up sound when a visitor finishes reading a Webflow article, using the Web Audio API.
Example
🎮
Level-up sound
Do Mi Sol Do — Web Audio API
Click to test
| Note | Frequency | Timing |
|---|---|---|
| Do | 523 Hz | 0ms |
| Mi | 659 Hz | 120ms |
| Sol | 784 Hz | 240ms |
| Do (high) | 1047 Hz | 360ms, held 300ms |
Understanding the melody
The Do-Mi-Sol-Do melody is the chord progression most universally recognized as a "victory" sound in gaming culture. It uses the Web Audio API's square oscillator for a retro 8-bit feel. No audio file is needed: everything is generated synthetically.
1. Add a level-up badge (optional)
Create a Div with the ID levelup-badge, set it to Fixed position, center it, and keep it hidden by default with display none. Add a message like "⬆ Level Up ! Article complete" in your own style.
2. Add the script in Footer code
(function() {
var fired = false;
function playLevelUp() {
var AudioCtx = window.AudioContext || window.webkitAudioContext;
if (!AudioCtx) return;
var ctx = new AudioCtx();
// Level-up melody: do-mi-sol-do (upper octave)
var notes = [
{ freq: 523, start: 0, dur: 0.1 }, // Do
{ freq: 659, start: 0.12, dur: 0.1 }, // Mi
{ freq: 784, start: 0.24, dur: 0.1 }, // Sol
{ freq: 1047, start: 0.36, dur: 0.3 }, // Do (high)
];
notes.forEach(function(note) {
var osc = ctx.createOscillator();
var gain = ctx.createGain();
osc.connect(gain);
gain.connect(ctx.destination);
osc.type = 'square';
osc.frequency.setValueAtTime(note.freq, ctx.currentTime + note.start);
gain.gain.setValueAtTime(0.15, ctx.currentTime + note.start);
gain.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + note.start + note.dur);
osc.start(ctx.currentTime + note.start);
osc.stop(ctx.currentTime + note.start + note.dur + 0.01);
});
}
window.addEventListener('scroll', function() {
if (fired) return;
var scrolled = window.scrollY + window.innerHeight;
var total = document.documentElement.scrollHeight;
if (scrolled >= total - 100) {
fired = true;
playLevelUp();
var el = document.getElementById('levelup-badge');
if (el) {
el.style.display = 'flex';
setTimeout(function() {
el.style.opacity = '0';
el.style.transition = 'opacity 0.5s';
setTimeout(function() { el.style.display = 'none'; }, 500);
}, 3000);
}
}
}, { passive: true });
})();3. Combine it with confetti
For a complete experience, load canvas-confetti in the head and add this inside the triggerEnd function:
if (typeof confetti === 'function') {
confetti({ particleCount: 80, angle: 60, spread: 55, origin: { x: 0, y: 0.8 } });
confetti({ particleCount: 80, angle: 120, spread: 55, origin: { x: 1, y: 0.8 } });
}Conclusion
A level-up sound creates a memorable moment and reinforces the feeling of accomplishment. Use cases:
- Long technical articles that reward finishing the read
- Tutorials with gamification
- Academies and training platforms


