The constraint

Every page on stingrayio.com is served with this header. You can see it yourself with curl -sI https://stingrayio.com/.

content-security-policy: default-src 'self'; img-src 'self' data:;
  style-src 'self'; script-src 'self'; object-src 'none';
  base-uri 'none'; form-action 'none'; frame-ancestors 'none';
  upgrade-insecure-requests

The two directives that matter here are style-src 'self' and script-src 'self'. No style attribute on any element. No <style> block. No <script> with code inside it, no onclick. Style and script come from files on this origin or they do not run. The policy is cheap to keep on a static site with no forms and no third-party anything.

Then I redesigned the site and wanted motion. Four things, each chosen because it shows something true about the work:

  • In the hero, a request enters a drawn system at the edge, is checked by identity, lights the application, fans out to data and logs, and a green response returns. Every nine seconds.
  • On one of the work cards, an operations log where lines arrive one at a time and roll.
  • A short light travelling along the circuit traces in the background, one every few seconds.
  • Sections that rise fourteen pixels and fade in as they scroll into view, and on the local-business page, a six-item check list that ticks green in sequence.

None of it needs a library. The question was where each piece could legally live.

Rule one: everything presentational is in the stylesheet

The wires drawing themselves in, the nodes popping, the rolling log and the trace pulses are CSS animations. They sit in one block near the end of style.css, inside @media (prefers-reduced-motion: no-preference), so a reader who has asked their operating system for less motion gets none of it. The wire draw is the stroke-dash trick: a dash as long as the path, offset by its own length, animated back to zero.

.sys .wire {
    stroke-dasharray: 420;
    stroke-dashoffset: 420;
    animation: draw 1.4s ease-out forwards;
}
.sys .wire:nth-of-type(2) { animation-delay: 0.1s; }
.sys .node { opacity: 0; animation: pop 0.3s ease-out 1.3s forwards; }

@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop  { to { opacity: 1; } }

The log is the same idea applied to opacity: one twelve-second keyframe, and a delay that steps by 0.7 seconds through :nth-child, so the lines appear in order and fade together before the loop restarts. The trace pulse is a seventy-unit dash on a 1,700-unit gap, slid along a copy of one background trace. No element in the HTML carries any of this. They carry a class name.

Rule two: SVG animation is markup, not script

The packet moving through the hero diagram is the one piece CSS does not do well, because it has to follow a bent path and stop at a node. SVG has had this since before CSS animations existed: <animateMotion> and <animate>, the declarative animation elements usually called SMIL. They are child elements of the shape they move, and the browser treats them as part of the document, the same as a <circle>. The script-src directive never comes into it. This is the first packet, the request arriving from the edge:

<g class="pk">
  <circle r="4" fill="#00D2FF" opacity="0">
    <animateMotion dur="9s" begin="1.6s" repeatCount="indefinite"
        calcMode="linear" path="M140,70 L200,70 L230,100 L230,160"
        keyPoints="0;1;1" keyTimes="0;0.2;1"/>
    <animate attributeName="opacity" dur="9s" begin="1.6s"
        repeatCount="indefinite" values="0;1;1;0;0"
        keyTimes="0;0.01;0.19;0.21;1"/>
  </circle>
</g>

Five packets share one nine-second clock. keyPoints and keyTimes say which slice of it each one moves in: the second packet waits until 4 percent, the two fan-out packets leave at 32 percent, the green response starts back at 58 percent. begin="1.6s" holds everything until the wires have drawn. The application box brightens on the same clock with an <animate> on its stroke opacity, and the data and logs boxes change stroke colour when their packet arrives. All of it is attributes on elements. View source and you can read the whole choreography.

Rule three: one small external script, and only for what needs it

Two things cannot be done without script. Revealing a section when it scrolls into view needs an IntersectionObserver. And pausing the SVG animations for readers who prefer reduced motion needs a method call, because SMIL does not read the CSS media query. The stylesheet can hide the packets, and it does, but the animations keep running underneath. pauseAnimations() on the <svg> element is what stops them.

So there is one file, /site.js, 38 lines, loaded with a plain <script src> tag at the bottom of every page. This is the reduced-motion part:

var reduce = window.matchMedia("(prefers-reduced-motion: reduce)");

function syncSvg() {
    document.querySelectorAll("svg.sys, svg.band-bg, svg.hero-bg")
        .forEach(function (svg) {
            if (typeof svg.pauseAnimations !== "function") { return; }
            if (reduce.matches) { svg.pauseAnimations(); }
            else { svg.unpauseAnimations(); }
        });
}
syncSvg();
reduce.addEventListener("change", syncSvg);

The listener matters: a reader can flip the preference while the page is open. And this is the reveal:

var targets = document.querySelectorAll(".reveal, .check-list");
if (reduce.matches || !("IntersectionObserver" in window)) {
    targets.forEach(function (el) { el.classList.add("is-in"); });
    return;
}
root.classList.add("js");
var io = new IntersectionObserver(function (entries) {
    entries.forEach(function (entry) {
        if (!entry.isIntersecting) { return; }
        entry.target.classList.add("is-in");
        io.unobserve(entry.target);
    });
}, { rootMargin: "0px 0px -8% 0px", threshold: 0.08 });
targets.forEach(function (el) { io.observe(el); });

The class that keeps the page honest when script does not run

A scroll reveal has to hide the section first. The failure mode is a reader with script blocked, or a script that fails to load, who gets a page of invisible sections. So the stylesheet never hides anything on its own. The hidden state is written as .js .reveal, and the js class is added to the root element by the script, after it has decided it will do the revealing:

.js .reveal { opacity: 0; transform: translateY(14px); }
.js .reveal.is-in {
    opacity: 1;
    transform: none;
    transition: opacity 0.55s ease, transform 0.55s ease;
}

Read the script again with that in mind. If the reader prefers reduced motion, or the browser has no observer, every target is marked is-in and the function returns before the js class is ever set. Three outcomes, and all three show the content: no script, everything visible; a script that opted out, everything visible; a script that opted in, everything revealed as it arrives. The check list on the local page uses the same gate, each tick drawn by a keyframe on the check-mark path with a delay that steps by 0.35 seconds per item.

The reduced-motion block, belt and suspenders

The end of the stylesheet turns everything off a second way, in case something above it slips:

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    * { transition: none !important; animation: none !important; }
    .sys .pk { display: none; }
}

That last line hides the packets. It does not stop them. With the script running, pauseAnimations() stops them as well, and the two together are the whole answer.

The check that nearly fooled me

I check every page at phone width before it ships. Desktop Chrome will not shrink its window much below 1,280 pixels, so the phone check runs in a headless browser with the window set to 390 wide and a full-page screenshot. The screenshot of the new home page came back with the hero copy and the buttons cut off at the right edge. That is exactly what horizontal overflow looks like, and I spent a while looking for a wide element that was not there.

It was not the page. The headless browser had laid the page out at its own minimum window width, wider than 390, and cropped the capture to the width I asked for. What settled it was a different measurement: a plain page holding a 390-pixel-wide <iframe> of the site, and the framed document's scrollWidth read out. It was 390. No overflow. A screenshot is a picture, not a measurement. When the picture says something is wrong, get the number before chasing the cause.

Before shipping motion under a strict policy

  • Confirm the header is still what you think it is: curl -sI the live page and read the policy back.
  • Grep the built pages for the style attribute, <style blocks and <script> tags with content. The count should be zero.
  • Put every keyframe and transition inside a prefers-reduced-motion: no-preference block.
  • If any SVG uses animateMotion or animate, call pauseAnimations() under reduced motion and listen for the preference changing. The media query alone will not stop it.
  • Hide nothing in the stylesheet except under a class only the script sets, and set it only after the script has committed to revealing. Then load the page with script disabled and confirm everything is readable.
  • For phone width, measure scrollWidth inside a fixed-width frame rather than trusting a headless screenshot.