Yes, even the logo. Hold 3.

The page less traveled.

This headline is fair game. Try 2.

A browser toy for vehicular misconduct. Add one script and turn your page into a destructible playground.

What’s possible

Get started

One script turns your existing HTML into a playground. No new layout required.

index.htmlHTML
<h1
  data-jr-breakable
  data-jr-burnable
>
  Page title
</h1>

<script
  type="module"
  src="https://unpkg.com/@joy-ride/game@latest/embed.js"
  data-jr-mount
></script>
  1. Add Joy Ride

    Paste the script into your page, or mount it from JavaScript.

  2. Choose what reacts

    Make a heading breakable or an image burnable with a data attribute or ride.bind().

  3. Take it for a drive

    Use WASD or the arrow keys to drive. Click the car to choose a vehicle and tools.

Source

Objects

Turn ordinary text, artwork, and buttons into things you can break, push, paint, or crush. Choose “Drive here” to try an example.

02.1Breakable

Break text into pieces

Text and SVG artwork break where they are hit.

breakable.htmlHTML
<h3
  data-jr-breakable
>
  BREAK THIS
</h3>
Live HTML

BREAK THIS

Hold 2 to shoot · 4 for a rocket.
02.2Pushable

Move individual letters

Each character moves independently when hit or pulled.

pushable.htmlHTML
<h3
  data-jr-pushable
>
  MOVE ME
</h3>
Live HTML

MOVE ME

Bump the letters or blast them with 4.
02.3Paint

Turn color into tire tracks

Drive through a colored element to coat your tires. Mix colors and leave tracks across the page.

View the code
paint.htmlHTML
<div
  data-jr-liquid="paint"
  style="background: #e03139; width: 144px; height: 144px;"
>
</div>

<button
  data-jr-liquid="paint"
  class="rounded-xl bg-sky-500 px-6 py-4 text-white"
>
  Blue paint
</button>
<button
  data-jr-liquid="paint"
  class="rounded-xl bg-amber-400 px-6 py-4 text-black"
>
  Yellow paint
</button>
Live HTML
Try both paint colors
Drive through blue, then yellow. The paint on your tires mixes into green.
02.4Crushable

Crush an image

Drive over an image to reveal its crushed version. Add a colored spill for a messy finish.

View the code
crushable.htmlHTML
<div
  class="ant"
  data-jr-crushable
  data-jr-crushable-crushed-class="is-crushed"
  data-jr-crushable-crushed-paint-color="#8caa27"
>
  <img class="alive" src="ant.webp" alt="Ant" />
  <img class="crushed" src="ant-crushed.webp" alt="" />
</div>

<style>
  .ant .crushed { display: none; }
  .ant.is-crushed .alive { display: none; }
  .ant.is-crushed .crushed { display: block; }
</style>
Live HTML
Drive over the ants. Cover at least half to crush one.
02.5Solid

Make an obstacle

The car and loose pieces collide with this element.

solid.htmlHTML
<div
  data-jr-solid
>
  WALL
</div>
Live HTML
WALL
Drive into the wall. Hold 5 to pass through in ghost mode.

Tools

Choose a tool, try it in a live example, then hold its number key. Steer to aim.

Hold 1 near the liquid playground.
Configure this tool
tools.jsJavaScript
await ride.ready;
ride.player.update({
  "slots": {
    "1": {
      "action": "eject",
      "liquid": "oil",
      "activation": "hold",
      "rate": 6,
      "amount": 0.65
    }
  }
});

Fire

Hold 3 to ignite a word, an illustration, or a puddle of oil. Let go and watch nearby materials catch.

04.1Text

Across separate words

Light one word and watch the next one catch. Separate elements can spread fire to each other.

View the code
fire-text.htmlHTML
<span
  data-jr-burnable
>
  SPARK
</span>
<span
  data-jr-burnable
>
  SPREADS
</span>
Live HTML
SPARKSPREADS
Hold 3 on the first word, then let go.
04.2SVG

Through vector artwork

Fire follows the lines of the illustration and gradually burns away the artwork.

fire-svg.htmlHTML
<svg
  viewBox="0 0 160 120"
  data-jr-burnable
>
  <path d="M8 60 46 44 73 8 89 48 144 28 118 66 152 106 92 86 64 116 54 78Z" />
</svg>
Live HTML
Hold 3 near a tip of the shape.
04.3Liquid

Across a wet fuel puddle

A puddle keeps its shape as it burns. The flames can spread from fuel to nearby burnable objects.

fire-liquid.htmlHTML
<div
  data-jr-liquid="oil"
>
  OIL
</div>
Live oil fire
Hold 3 toward the oil puddle.
04.4Mixed materials

A chain reaction

Start at the word and watch fire travel through paint, fuel, and artwork. Different materials make one chain reaction.

View the code
fire-chain.htmlHTML
<span
  data-jr-burnable
>
  INK
</span>
<div
  data-jr-burnable
  style="background: #e03139"
>
  SURFACE
</div>
<div
  data-jr-combustible
  data-jr-combustible-health="70"
>
  FUEL
</div>
<svg
  data-jr-burnable
  viewBox="0 0 80 80"
>
  <path d="M40 2 49 28 77 28 55 45 63 75 40 58 17 75 25 45 3 28 31 28Z" />
</svg>
Live HTML
INK
SURFACE
FUEL
Tap 3 on INK, release, and watch the fire pass along.

Liquids

Spill oil, splash water, or mix paint with your tires. Pick a liquid, pour it, and drive back through the trail.

Oil recipe

Burnable. Reduces grip for four seconds.

View the liquid recipe
oil.jsJavaScript
const kit = JoyRide.define({
  liquids: {
    'demo-oil': {
      "base": "oil",
      "color": "#151919",
      "thickness": 0.86,
      "burnable": true,
      "effect": {
        "lifetime": {
          "unit": "seconds",
          "amount": 4
        },
        "modifiers": {
          "grip": 0.28
        }
      }
    },
  },
});

const ride = JoyRide.mount({ definitions: kit });
await ride.ready;
ride.player.update({
  slots: { 1: { action: 'eject', liquid: 'demo-oil' } },
});
Live liquid recipe
1Hold to pour oilDrive back through the trail to coat your tires.
Hold 1 while driving to leave a trail.

Interactions & objectives

Give the drive a purpose: press buttons, make a delivery, or collect pickups. Add points and objectives to turn a page into a game.

Buttons & switchesDrive into either control, or click it yourself.
Make a delivery

Park at 1 → cross 2 → park at 3.

0 / 3 stops complete
01CollectStop inside to pick upReady when you are
02Pass throughDrive straight acrossReady when you are
03DeliverStop inside to finishReady when you are
EnteredHold stillComplete
Collect three pickupsEach pickup adds 10 points and sends a color ripple through your car.0 / 3 collected
✦✦✦

Objectives can also count crushed, broken, or ignited targets, or challenge visitors to reach a score.

Build an interaction or objective
events.htmlHTML
<button
  data-jr-trigger="click"
>
  Press me
</button>
<input
  type="checkbox"
  data-jr-trigger="toggle"
/>

<div
  id="parking"
  data-jr-trigger="parking"
  data-jr-points="50"
  data-jr-trigger-dwell-seconds="0.6"
  data-jr-trigger-success-class="is-success"
>
  Park here
</div>

<div id="pickups">
  <span
    data-jr-trigger="pickup"
    data-jr-pickup-effect-color="#349dff"
    data-jr-trigger-event="pickup-collected"
    data-jr-points="10"
  >
    ✦
  </span>
  <span
    data-jr-trigger="pickup"
    data-jr-pickup-effect-color="#ad66ff"
    data-jr-trigger-event="pickup-collected"
    data-jr-points="10"
  >
    ✦
  </span>
  <span
    data-jr-trigger="pickup"
    data-jr-pickup-effect-color="#31d9ba"
    data-jr-trigger-event="pickup-collected"
    data-jr-points="10"
  >
    ✦
  </span>
</div>
<output
  id="score"
  data-jr-hud="points"
>
  0
</output>
events.jsJavaScript
ride.objective('supplies', {
  type: 'collect', count: 3,
});
ride.on('objective:complete', ({ objective }) => {
  console.log('Complete:', objective.id);
});

ride.objective('high-score', { type: 'score', points: 30 });

document.querySelector('#parking').addEventListener(
  'joyride:trigger:stop', ({ detail }) => {
    console.log('Parked:', detail.vehicle.id);
  },
);

// Points update the shared score HUD automatically.
// Events bubble: one listener handles every pickup.
document.querySelector('#pickups').addEventListener(
  'joyride:pickup-collected', ({ detail }) => {
    console.log('Collected:', detail.object.id);
  },
);

Driving

Try donuts, drifts, and burnouts. Leave tire marks and smoke as you find your own way around.

07.1Handling & tire smoke

Handling & tire smoke

Try a maneuver with your current car. Tire smoke follows its motion and flows around walls.

Tune the handling
handling.jsJavaScript
const kit = JoyRide.define({
  vehicles: {
    'my-car': {
      base: 'porsche-911-997',
      drift: { entrySpeedMps: 4.5, slipAngleRad: 0.3 },
    },
  },
});

JoyRide.mount({
  definitions: kit,
  player: { vehicle: 'my-car' },
});
Your current ride
Try a maneuver
WAD
Hold throttle and full steering to draw a circle.

Debris

Scatter paper and leaves around an element. Drive past to disturb them.

Both materials / drive through or send a gust
Live airflow / 45 pieces

Mixed debris

A small mix of paper and leaves. Drive past to disturb it.

Add debris to your page

HTML

Choose where the pieces begin.

debris.htmlHTML
<div
  data-jr-debris
  data-jr-debris-anchor="fill"
  data-jr-debris-amount="45"
  data-jr-debris-seed="31"
>
  Your content
</div>

JavaScript

Scatter pieces, reset them, or remove them from your page.

debris.jsJavaScript
await ride.ready;
const litter = ride.debris('.track', {
  anchor: 'fill',
  amount: 45,
  // Paper and leaves by default.
  seed: 31,
});

litter.gust({ x: 300, y: -65 });
litter.reset();
// litter.dispose();

Everything else

The little touches: an engine that responds, a horn, slow motion, lights, and a dashboard of your own.

Engine sound & horns

Hear the engine rev and the tires squeal. Each car has its own sound and horn.

Hold H to honk
0 rpmGear N
Customize the horn
sound.jsJavaScript
const kit = JoyRide.define({
  vehicles: {
    'my-car': {
      base: 'porsche-911-997',
      sound: {
        horn: { lowHz: 380, highHz: 480, tone: 'trumpet', level: 0.6 },
      },
    },
  },
});

const ride = JoyRide.mount({ definitions: kit, player: { vehicle: 'my-car' } });
// Start sound from a click or another user gesture.
await ride.startAudio();

Slow motion

Take in the chaos at half speed. The action and audio slow down together.

VHold to slow down. Release to return to normal speed.
Control slow motion
slow-motion.jsJavaScript
await ride.setSlowMo(true, {
  speedFactor: 0.5,
  rampMs: 300,
  zoomFactor: 0,
});

await ride.setSlowMo(false);

Lighting & contrast

Lights, tire marks, and vehicle details adapt to the ground beneath the car.

U toggles underglow
Configure the lighting
lighting.jsJavaScript
ride.updateSettings({game:{headlights: true,underglow: '#66e6ff',underglowOpacity: 0.6}});

Live readouts

Put speed, gear, points, and other live values into your own HTML.

Use data-jr-hud-unit="kmh" for kilometres per hour, or data-jr-hud-precision="1" for a decimal place.

Add live readouts
readouts.htmlHTML
<output
  data-jr-hud="speed"
>
  0
</output> mph
<output
  data-jr-hud="gear"
>
  N
</output> gear
<output
  data-jr-hud="rpm"
>
  0
</output> rpm
<output
  data-jr-hud="health"
>
  0
</output> health
<output
  data-jr-hud="points"
>
  0
</output> points
<output
  data-jr-hud="fps"
>
  0
</output> fps

Your page is next

Make your page the playground.

Add the script, choose what reacts, and give visitors something to play with.

Explore the docs