WebGL is just an OpenGL ES 2 binding to JavaScript. OpenGL ES 2/3 is a subset of OpenGL 3/4. Angle translate GLSL shaders and OpenGL calls to DirectX
Not to mention vendor specific extensions and workarounds driver bugs.
So one ends with multiple code paths, if several versions are to be supported. Similar to how HTML or POSIX are portable, but then again not so much.