How we built a 24KB WebGL shader

6snm0 Oct 18, 2026 9 min read Lab notes
How we built a 24KB WebGL shader

Modern creative agency websites frequently ship 8MB Three.js bundles just to render a wobbly liquid blob. We set out to prove that editorial WebGL can be delivered with zero external libraries and a total compressed footprint under 24KB.

Raw WebGL 2.0 with zero libraries

By compiling raw vertex and fragment GLSL shaders directly against the browser’s native WebGL2RenderingContext, we eliminate Three.js, Babylon, and extraneous math libraries completely.

#version 300 es
precision highp float;
uniform vec2 u_res;
uniform float u_time;
out vec4 fragColor;
// Procedural liquid refraction in under 40 lines of GLSL

Simplex noise and chromatic dispersion

The liquid chrome effect relies on a single fullscreen quad rendering 3D simplex noise with raymarched normal offsets and three-channel refractive dispersion (red, green, blue refracted at differing indices).

Zero impact on main thread scrolling

The entire render loop runs in an OffscreenCanvas on a dedicated Web Worker thread. Even under intense mouse scrub interactions, the main UI thread never drops a single frame below 60fps.

Written by 6snm0 More about 6snm0 ↗

Keep reading

All notes ↗

1 response

  1. John Doe · 2 months ago

    This is an insightful article on WebGL shader optimization.

Leave a response
Be kind ✺