HTML in Canvas: Bridging UI and GPU on the Web

This ad is not shown to multipass and full ticket holders
React Advanced
React Advanced 2026
October 23 - 26, 2026
London, UK & Online
Upcoming event
React Advanced 2026
React Advanced 2026
October 23 - 26, 2026. London, UK & Online
Bookmark
Rate this content
Sentry
Promoted
Code breaks, fix it faster

Crashes, slowdowns, regressions in prod. Seer by Sentry unifies traces, replays, errors, profiles to find root causes fast.

Get started

Modern web development still relies on a strong separation between HTML/CSS for UI and Canvas/WebGL for rendering. In practice, combining both often leads to complex synchronization logic and a series of workarounds.

In this talk, we’ll first walk through how these problems are typically solved today — including scroll synchronization, frame loop timing, scissor-based rendering, and mapping DOM elements into a WebGL scene — and why these approaches tend to be fragile and hard to scale.

Using a set of experiments and websites developed at basement.studio, we’ll show these patterns in practice, combining real layouts with shaders and interactive effects.

From there, we’ll introduce HTML-in-Canvas and show how it simplifies many of these problems — not as a finalized solution, but as a direction that removes the need for most of the synchronization and rendering workarounds we rely on today.

We’ll also cover the challenges of building UI directly in WebGL, where layout, text, and interactivity become difficult to manage, especially in environments like WebXR.

This talk has been presented at JSNation 2026, check out the latest edition of this JavaScript Conference.

Santiago Colombatto
Santiago Colombatto
Tomas Ferreras
Tomas Ferreras
17 min
15 Jun, 2026

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Santiago Colombato explains the challenge of synchronizing DOM and WebGL for visually heavy websites, focusing on scroll sync and WebGL basics. WebGL scroll sync involves adjusting canvas position to prevent drift. Optimizing WebGL text rendering includes overcoming drift and clipping challenges. WebGL font rendering complexities include manual handling of text features. Enhancements involve drawing real HTML elements inside the canvas for visual effects. WebXR demos showcase HTML integration in 3D space, emphasizing aesthetics and accessibility.

1. Understanding DOM and WebGL Sync

Short description:

Santiago Colombato, a front-end developer, discusses the challenge of synchronizing DOM and WebGL for visually heavy websites, focusing on scroll sync and the basics of WebGL, including shaders and rendering with the GPU.

Hi, everyone. I'm Santiago Colombato. I work as a front-end developer at Basement Studio. We build sites and experiences with companies like Brazil, Daylight, MrBeast, and a lot of what we ship uses WebGL.

Today, I want to talk about a gap that we keep running into, and that gap is making the DOM and WebGL move as one. When you build a visually heavy website, you usually have two phases to manage. One side, it's the DOM. It gives you layout, text, scroll, accessibility, and the other is WebGL, shaders, GPU rendering, cool effects, basically. The challenge starts when both need to stay in sync, and the hard part is making them move as one.

So, I'm going to focus on one specific problem today, and that is scroll sync. But first, most of you write JavaScript, but not everyone writes WebGL, so let me take a minute to cover the basics so we can understand the full context. When you work on a normal web page, you write HTML and CSS, the browser calculates layout, paint text, and elements, and everything works. You don't think too much about the GPU.

WebGL changes that. WebGL is a JavaScript API that lets you render graphics inside a canvas element. You work directly with the GPU. But the trade-off here is that you leave the normal rendering pipeline of the browser. Inside the canvas, you don't have HTML. You don't have CSS. So, you're just drawing pixels with little programs that run on the GPU. Those programs are called shaders. We have two types of shaders. The first one is the vertex shader. Every shape on canvas is made of triangles, and triangles are made of points or vertices. So, as you can see on the slide, this code snippet is a basic vertex shader.

2. Solving WebGL Scroll Sync

Short description:

The vertex and fragment shaders handle positioning and color decisions in WebGL. Hybrid website models use both DOM and WebGL for heavy visual work, requiring synchronization to avoid discrepancies during scrolling. Adjustment of the canvas position and top offset can resolve drift issues in WebGL layers during scrolling.

That program runs once per vertex, and the job is simple. Take a 3D position, output a screen coordinate. If you want to move, scale, or transform something on WebGL, you will be working with the vertex shader. The second one is the fragment shader. Once the GPU knows where the triangles are, it fills them in. So, for every pixel inside a triangle, the fragment shader decides what color to write. Think of visual effects, lights, textures. All of that is the fragment shader, answering the same question millions of times per frame. What color should this pixel be?

So, basically, the vertex shader decides where, and the fragment shader decides what it looks like. If you look at visually heavy websites like this one, they will use this hybrid model for sure. The DOM is still there, but the canvas is doing a lot of the heavy visual work. The results can look great, but there's a cost. The browser understands the DOM, but your WebGL scene is like a black box. So, we need to make them agree. And scroll is where things start to break. When you scroll a page, the browser updates the visual scroll position immediately. But your WebGL layer updates from JavaScript, inside a frame loop, from a sample value after the scroll. So, you have two systems that are close in time, but they are not the same.

The browser moves the page, and the canvas reacts a frame later. Usually, you barely notice this, but we don't want that. So, let me show you a real case. We have a demo here with a WebGL scene that draws this leader effect on top of images. And if I scroll, you will see that the WebGL layer drifts. So, we need to fix this. And the first thing we can do is fix the canvas, and pass the top offset to match the scroll on every frame. So, basically, you're making the canvas position absolute, and you are updating the top offset to match the scroll. This removes the drift. But please check this, the edges of the canvas. They are clipping. So, we are getting close.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Boost the Performance of Your WebGL Unity Games!
JS GameDev Summit 2023JS GameDev Summit 2023
7 min
Boost the Performance of Your WebGL Unity Games!
Top Content
The Talk discusses ways to boost the performance of WebGL Unity games, including issues with bundle size, memory usage, and runtime performance. It suggests using Brotli for compression and non-exception support for better performance. Choosing the appropriate texture compression format and experimenting with separate builds can also help. The Talk also covers optimizing textures, models, audio, and assets by reducing build size, using compression, disabling unnecessary models, and optimizing audio quality. Unity's optimization tools and profilers are recommended for analyzing performance and memory issues.
Unreal Engine in WebAssembly/WebGPU
JS GameDev Summit 2022JS GameDev Summit 2022
33 min
Unreal Engine in WebAssembly/WebGPU
Top Content
Alex Saint-Louis, co-founder of Wunder Interactive, shares the mission of bringing Unreal Engine to the browser, enabling cross-platform 3D applications and games. They are working on a WebGPU back end for Unreal Engine to push the limits of 3D on the web. Wunder Interactive has improved compression, built their own asset file system, and offers powerful tools for game developers. They are utilizing modern web technologies like WebAssembly, WebGL, and WebGPU, and plan to support other engines like Unity and Godot. The team aims to transform the industry by bringing console-quality games to the browser and providing an alternative distribution path. They are excited to bring Unreal Engine 5 to the web with WebGPU support and are working on WebXR support for cross-platform 3D experiences, including VR.
Detect and Avoid Common Performance and Memory Issues in Unity WebGL Builds
JS GameDev Summit 2022JS GameDev Summit 2022
10 min
Detect and Avoid Common Performance and Memory Issues in Unity WebGL Builds
Top Content
Today's Talk focuses on avoiding performance and memory issues in Unity WebGL builds. The importance of managing memory and keeping the heap size small is highlighted. Techniques such as using asset bundles or an addressable system can help reduce memory usage. The limitations of garbage collection in WebGL builds are discussed, along with tips for optimizing Unity code. Tools like Backtrace can assist in debugging memory and performance issues.
Extending Unity WebGL With Javascript
JS GameDev Summit 2022JS GameDev Summit 2022
32 min
Extending Unity WebGL With Javascript
Top Content
Unity targets over 25 platforms and technologies, including desktop, mobile, and virtual reality. They use Emscripten to compile the engine and game logic into WebAssembly for web development. Unity can be extended with plugins to access browser features like WebXR's augmented reality mode. The speaker demonstrates intercepting Unity's calls to the browser to modify its behavior. Unity is actively working on mobile support for web export and improving documentation for extending Unity with web plugins.
Pixi Powerups!
JSNation Live 2021JSNation Live 2021
30 min
Pixi Powerups!
Pixie is a powerful tool for creating scenes and effects in software development. It supports features like texture mapping, Spine animation, and filters for creating cool effects. The talk also covers the use of render textures to capture and download images, as well as the importance of communication and a positive attitude in software development. The speaker shares their journey into coding and discusses the potential for porting Unity games to JavaScript using technologies like web GL and web GPU.
Marrying WASM/WebGL Games with React UI
React Summit 2022React Summit 2022
22 min
Marrying WASM/WebGL Games with React UI
Jonny discusses marrying WebAssembly and WebGL games with React, emphasizing the importance of choosing the right tool for game development. He introduces the Godot game engine as a powerful choice for game development and highlights the limitations of Godot. Jonny demonstrates how to combine React with Godot and showcases the ability to dynamically switch between different games on the same website. He explains the process of exporting a Godot game to the web using WebAssembly. Jonny also discusses the communication between React and Godot games and highlights the benefits and future improvements of using this approach.

Workshops on related topic

Make a Game With PlayCanvas in 2 Hours
JSNation 2023JSNation 2023
116 min
Make a Game With PlayCanvas in 2 Hours
Top Content
Featured WorkshopFree
Steven Yau
Steven Yau
In this workshop, we’ll build a game using the PlayCanvas WebGL engine from start to finish. From development to publishing, we’ll cover the most crucial features such as scripting, UI creation and much more.
Table of the content:- Introduction- Intro to PlayCanvas- What we will be building- Adding a character model and animation- Making the character move with scripts- 'Fake' running- Adding obstacles- Detecting collisions- Adding a score counter- Game over and restarting- Wrap up!- Questions
Workshop levelFamiliarity with game engines and game development aspects is recommended, but not required.
How to make amazing generative art with simple JavaScript code
JS GameDev Summit 2022JS GameDev Summit 2022
165 min
How to make amazing generative art with simple JavaScript code
Top Content
Workshop
Frank Force
Frank Force
Instead of manually drawing each image like traditional art, generative artists write programs that are capable of producing a variety of results. In this workshop you will learn how to create incredible generative art using only a web browser and text editor. Starting with basic concepts and building towards advanced theory, we will cover everything you need to know.