HTML5Dynamic creativeJSON feedSVGCSS animationIntlpostMessage
Керування
- Pick an audience: London (GBP, English), Warsaw (PLN, Polish copy) or New York (USD); the same packages re-render with that feed
- Edit a city, price, weather, countdown or seats; every banner updates and restarts, and the JSON panel shows exactly what they receive
- Type a very long city name to see the headline shrink to fit instead of overflowing
- Retargeting makes a product you viewed yesterday the first fare and changes the first line and the button
- Break the feed sends invalid data; each banner rejects it, shows its default feed and reports the fallback
- Hover a banner to pause it; a banner scrolled out of view pauses itself
- Click a banner to see the exit URL with the destination code that the ad server would open
- Backups swaps in the static backup image; Replay restarts all six in sync
Works in current Chrome, Safari and Firefox; plain HTML, CSS, SVG and a little JavaScript in sandboxed iframes, no WebGL, no external requests and no font requests. Respects the reduced-motion setting: every banner shows its end card and the countdown does not tick. Orrery Air is a fictional airline; destinations, fares and dates are illustrative.
Питання
What is dynamic creative?
A banner whose content is filled from a data feed when it is shown, so one design can show different offers to different audiences.
How does the feed reach the banner?
A default feed is embedded as JSON, and an ad server can replace it with window.setFeed or a feed query parameter.
What happens if the feed is broken?
The feed is validated, and an unusable one falls back to the default offers.
Is Orrery Air a real airline?
No. It is a fictional airline made for this example.
Як це зроблено
How it's built
- Six standalone HTML5 packages in
public/lab/ads/fare-drop/ (bb 970×250, lb 728×90, mb 320×50, mr 300×250, hp 300×600, ws 160×600; neutral folder names because EasyList blocks URLs containing a size). Generated by node scripts/ads/fare-drop.mjs (CSS and compositions, three illustrated scenes from fare-drop-scenes.mjs, the runtime from fare-drop-runtime.js minified with rolldown), then npm run ads measures them. Each is one index.html with inline CSS, SVG, script and two subset fonts (DM Serif Display and Manrope Bold, SIL OFL, base64), plus backup.jpg; about 120-140 KB with the backup, no external requests. - It is a dynamic creative: the default feed is a JSON block in the file (
<script type="application/json" id="feed">, the London audience from presets.json), and the runtime builds one slide per offer from it. Ad servers can call window.setFeed(feed) or pass ?feed=<json>; the Lab posts {cmd: "feed"}. norm() validates the feed (locale and currency checked through Intl, prices, codes, scenes and weather whitelisted, strings clamped) and an unusable feed falls back to the default and reports feed-fallback. - Copy is data: kicker, labels, button text, weather names and the currency format come from the feed, so Warsaw gets Polish and PLN with no code change. Prices render through
Intl.NumberFormat.formatToParts into an odometer (each digit a column of numerals that rolls to its value with CSS only); dates through Intl.DateTimeFormat; the countdown ticks from endsIn seconds; the discount is computed from the "was" price. - Retargeting: a feed with
viewed: "HND" moves that offer first, changes the first kicker to "Still thinking about Tokyo?" and the button to "Back to Tokyo". - Headlines are fitted to their box after fonts load (
fit() shrinks the font down to half), and digit columns are sized to the real digit width. - Timeline: 5 s per offer, three offers, then an end card (lowest fare, the three destinations, "See all fares"). All animation is CSS on
transform and opacity with animation-delay: var(--sd), so a frame can be seeked to any time (?at=ms freezes one; ?end shows the end card). A coral curtain wipes the scene between offers. Weather overlays (rain, snow, blossom, cloud, glints) and the scene loops (aurora, tram, beacon) are decorative CSS. Under reduced motion the banner shows its end card. - Quality rules in every package:
ad.size meta, global clickTag with a per-destination exit (?dest=LIS&from=LHR), full-size click area, pause on hover and when out of view (IntersectionObserver), backup image, 150 KB budget, text set by textContent-safe escaping, sandboxed in the Lab. - The Lab page is a console over the proof sheet: audience tabs (three feeds in
presets.json), editable fares, retargeting, "Break the feed", a live feed.json view, and the six frames with spec tags from manifest.json (npm run ads). - Fictional brand: Orrery Air; destinations, fares and dates are illustrative.