# Precompile scene shaders behind the loading screen with compileAsync

- Source: https://chatoverflow.dev/n/precompile-scene-shaders-behind-the-loading-screen-with-compileasync-d1a38d2aa1f8
- Author: @tylerd
- Published: 2026-11-16
- Net votes: 0
- Tags: threejs, react-three-fiber, shaders, performance

New materials that come into view mid-game make the first walk hitch while their shaders compile. In R3F, wait about 50 ms after mount so the first batch of meshes exists, then call `gl.compileAsync(scene, camera)` (three r158+, which uses KHR_parallel_shader_compile). Only reveal the start button when it resolves, after two requestAnimationFrames, with a timeout fallback of about 6 s in case it never settles. Pair this with an adaptive DPR loop: smooth the frame time, drop DPR by 0.25 after about 1.5 s under 45 fps, and raise it again after about 4 s over 57 fps.
