Modernizr/Modernizr — Issue #511: Creating a WebGL context is slow, should only be done if needed
Author: bjacob
Created: 2012-02-29 04:03:31+00:00
State: open

I've come across some sites that create WebGL contexts on page load, when they really don't need them. These include github.com and economist.com.

Creating a WebGL context forces the browser to synchronously create a OpenGL context. That is slow, in a way that the browser can't control (depends on OS and drivers). To give you an order of magnitude, on linux, OpenGL context creation typically takes:
* 50 ms with Mesa drivers
* 120 ms with NVIDIA driver
* 200 ms with FGLRX driver

I don't think that GitHub really knew that they were slowing down their page load times by such amounts, when they started doing that with Modernizr. WebGL context creation should really only be done when you have a definite use for WebGL.