Search notes:

WebGL: accessing source code from javascript

First, the source code is defined within a <script> tag whose type is explicitly not set to text/javascript:
<script id="fragment-shader-src" type="x-shader/x-fragment">
    varying lowp vec4 vColor;
    
    void main(void) {
      gl_FragColor = vColor;
    }
</script>
Then the source code is loaded with
var src_text = document.getElementById('fragment-shader-src').text;
Alternatively, the source code can also be stored in so called multi line strings.

See also

Graphic Library Shader Language

Index