Unity will produce a WebGL build from almost any project. Whether that build runs on the device a player is actually holding is a different question, and it is the question that decides whether a web port is worth doing.
Memory is the first wall
A WebGL build allocates a single contiguous heap. On desktop that is rarely a problem. On mobile Safari and on mid-range Android, the browser will refuse an allocation long before the device runs out of physical memory, and the failure is not graceful — the tab reloads or dies.
What actually helps:
- Set the memory size deliberately rather than leaving the default. Measure the real peak and set it just above, not comfortably above.
- Strip texture sizes hard. A 2048 atlas that looked free on desktop is not free here.
- Load scenes additively and unload what you leave. Every scene you keep resident is heap you cannot spend elsewhere.
Build size decides whether anyone waits
Instant-play portals exist because nobody installs anything. That advantage disappears if the first load takes forty seconds. The levers, in the order they pay off:
- Brotli compression, with the server configured to serve it. Gzip is the fallback, not the target.
- IL2CPP code stripping set to High, then fix what breaks. It will break something that uses reflection; that is the cost.
- Audio — compress aggressively and stream anything long. Uncompressed audio is the single most common reason a build is twice the size it needs to be.
- Unused packages. Open the manifest and remove what the project no longer imports. The default template carries more than most games use.
Things that work on desktop and silently do not on mobile web
- Audio before a user gesture. Mobile browsers block it. If your splash screen plays music, it plays silence.
- Deep pointer-lock and cursor behaviour. There is no cursor.
- Heavy post-processing. It compiles, it runs, and it runs at eleven frames per second.
- Threads. Available only where cross-origin isolation headers are set, and most portals do not set them for you.
Test on the thing, not the emulator
Chrome's device emulation tells you about layout. It tells you nothing about the memory ceiling, the GPU, or the thermal throttling that arrives ninety seconds in. A cheap Android handset on the desk is worth more than any emulator for this specific job.
This is what we do day to day — Unity to WebGL porting at Factorial Studio.