Make browser games work in Chrome, Edge, Firefox and Safari (including every iPhone browser, which are all Safari underneath). A test script that loads the game in Chromium, Firefox and WebKit and reports errors, missing features and screenshots side by side; tested helpers for feature detection with a plain-words report, browser info for bug reports, audio format choice, unlocking audio after ...
Download skill (.zip) Files on GitHubCross-browser compatibility
1. Test in three engines
python3 scripts/cross-browser.py http://localhost:8080 --out xb [--click "#play"] [--keys "ArrowRight,Space"]
Loads the game in Chromium (Chrome, Edge, Opera, Samsung), Firefox and WebKit (Safari, and every browser on iPhone),
at desktop and phone sizes. xb/REPORT.md lists each engine’s errors, missing features and a non-blank canvas check, with
screenshots side by side (xb/sheet.png). Exit code 1 when an engine has errors.
- Engines that aren’t installed are skipped and named in the report. Install with
playwright-cli install-browser firefox(andwebkit; WebKit also needs system libraries:install-deps webkit). - WebGL games: don’t load them in the sandbox browsers (no GPU). Use
--no-loadfor the feature list only, thencheck_gpu_renderand the viewer’s preview; ask for a real iPhone check. - Emulated WebKit is close to Safari but not the same: touch, audio, fullscreen and memory limits still need a real iPhone.
2. Detect features, not browsers
import { features, compatReport, browserInfo, pickAudio, unlockAudio, safeStorage, polyfills } from "./compat.js";
polyfills(); // roundRect, requestIdleCallback, structuredClone where missing
const f = features(); // { gamepad, vibrate, fullscreen, webAudio, localStorage, ... }
compatReport(f) // [{ feature, impact, fix }] only for what's missing
const store = safeStorage(); // never throws; store.persistent false = saves last this visit only
const music = pickAudio(["music.ogg", "music.m4a", "music.mp3"]);
unlockAudio(audioCtx); // resumes on the first tap, and after iOS interrupts audio
bug report line: JSON.stringify(browserInfo()) // { name, engine, version, ios, android, inApp }
The differences that break games
| Problem | Where | Fix |
|---|---|---|
| No sound until a tap; sound stops after a call or app switch | Safari, iPhone (all browsers), Chrome | unlockAudio; start audio from the title’s tap |
| Ogg/Vorbis not played | Older Safari | Ship .m4a or .mp3 too; pickAudio |
| No fullscreen | iPhone | fullscreen-management fallback, Add to Home Screen |
| No vibration | iPhone, desktops | haptic-feedback fallback |
100vh taller than the screen |
Mobile Safari, Chrome Android | 100dvh (with 100vh before it) |
| Storage throws or is wiped | Private modes, blocked cookies in iframes, Safari after 7 days unused | safeStorage, export saves, ask installed apps to persist |
| Page scrolls or zooms when playing | iPhone (double tap, pinch), Android pull-to-refresh | touch-action: none on the game, overscroll-behavior: none (mobile-game-controls) |
| Motion sensors need permission | iPhone | Ask in a tap (device-orientation-controls) |
e.key differs on layouts |
Every browser | Use e.code (game-control-customization) |
Canvas roundRect, filter, letterSpacing missing |
Older Safari and Firefox | polyfills, or avoid canvas filter (slow or missing in Safari) |
| WebGL context lost when backgrounded | Mobile | Handle webglcontextlost / restored (webgl-rendering) |
| Gamepad layout differs | Firefox on Linux, older Safari | Check mapping === "standard" (gamepad-support) |
| In-app browsers (Instagram, TikTok, Discord) | Odd storage, no fullscreen, no install | Detect inApp; offer “Open in browser” |
Device Lab (assets/device-lab)
A page that tries every module in this category on whatever device opens it: browser and feature chips, controller detection
and rumble, vibration (or a shake where there’s none), fullscreen, tilt, orientation, the quality governor with a stress
test, captions with sound direction, game speed, saved settings, and install. Serve the category folder and open
cross-browser-compatibility/assets/device-lab/. Open it in its own tab (not an iframe) to try installing.
Tested
Node tests: browser info for Safari, Chrome on iOS, iPadOS posing as a Mac, Edge, Firefox, Android and in-app browsers; audio choice; storage blocked and full; fallbacks; the missing-feature report; audio unlocking; detection without a DOM. The cross-browser script and the device lab were run in Chromium, Firefox and WebKit.
Pitfalls
Testing only in Chrome, sniffing the browser name to decide features, a single .ogg soundtrack, saves that crash on blocked storage, and assuming Chrome on iPhone behaves like Chrome on Android.