Make your landing page feel alive

Click any word to animate that one

The prompt

Written from your settings. Paste it into your AI tool.

Animate one word in the main headline of my landing page with an effect called Decipher. In my example the headline reads "Make your landing page feel alive" and the animated word is "alive". Apply it to the word I point out in my own headline, and ask me which one if I have not said. Keep the rest of the headline still. Replace each letter of that word with random characters picked from capital letters, digits and symbols, swapping them every 50ms. Lock the letters into their real value one at a time from left to right, starting after 300ms with 60ms between letters. Show scrambling letters in my accent colour and locked letters in the normal text colour. Run it again every 3.2 seconds so the word keeps deciphering itself. Give each letter a fixed width equal to its real width so nothing jitters while it scrambles. Keep my existing font, colours and layout exactly as they are. Screen readers and search engines must still read the headline as one normal sentence, so put the full text in an aria-label on the heading and mark any decorative spans as aria-hidden. If the visitor has prefers-reduced-motion turned on, show the finished headline straight away with no animation. Make sure nothing shifts the layout while it plays. Use plain CSS and a little vanilla JavaScript, unless my project already has an animation library, in which case use that. A live demo with reference code for these exact settings is at https://smthngfun.com/a/word-decipher and you can use that code as your starting point, adapted to my codebase and styling. If I am happy to credit the source, add a small "Animation by smthngfun" link to https://smthngfun.com in the footer of the page. Ask me before adding it.

Reference code

A working version of Decipher with your settings. It assumes the headline has the class hero-title.

<!-- HTML -->
<!-- Decipher animation from https://smthngfun.com/a/word-decipher -->
<h1 class="hero-title">Make your landing page feel <span class="decipher">alive</span></h1>

/* CSS */
.hero-title .decipher { display: inline-block; white-space: nowrap; }
.hero-title .decipher span { display: inline-block; text-align: center; }
.hero-title .decipher .pending { color: var(--accent, currentColor); }

// JavaScript
const target = document.querySelector('.hero-title .decipher');
const words = ['alive'];
const glyphs = 'ABCDEFGHJKLMNPQRSTUVWXYZ0123456789#%&/<>*+=';
let current = 0;
let frame = 0;

function decipher(word) {
  cancelAnimationFrame(frame);
  target.innerHTML = Array.from(word).map(function (ch) {
    return '<span class="pending">' + ch + '</span>';
  }).join('');
  const chars = Array.from(target.children);
  const size = parseFloat(getComputedStyle(target).fontSize);
  chars.forEach(function (c) {
    c.dataset.ch = c.textContent;
    c.style.width = c.getBoundingClientRect().width / size + 'em';
  });
  const start = performance.now();
  let last = 0;
  frame = requestAnimationFrame(function tick(now) {
    const swap = now - last > 50;
    if (swap) last = now;
    let done = true;
    chars.forEach(function (c, i) {
      if (!c.classList.contains('pending')) return;
      if (now - start >= 300 + i * 60) {
        c.textContent = c.dataset.ch;
        c.classList.remove('pending');
      } else {
        done = false;
        if (swap) c.textContent = glyphs[Math.floor(Math.random() * glyphs.length)];
      }
    });
    if (!done) frame = requestAnimationFrame(tick);
  });
}

if (!matchMedia('(prefers-reduced-motion: reduce)').matches) {
  decipher(words[0]);
  setInterval(function () {
    current = (current + 1) % words.length;
    decipher(words[current]);
  }, 3200);
}