Early depth test in WebGL
In my answer I relate to WebGL 2 / Opengl ES 3.0. 

As far as I know ARB_shader_image_load_store is not supported. But there is discard available for fragment shaders in WebGL 2! So what you can do is to


make a depth pass with a straight-forward fragment shader and 
then in a second pass test gl_FragCoord.z against the value of the depth texture.


It's up to you, if it's worth the additional texture lookup and rendering the scene twice.