createShaderFromScript = function (
  gl, scriptId, optShaderType, optErrorCallback
) {
  var shaderSource = '';
  var shaderType;
  var shaderScript = document.getElementById(scriptId);
  if (!shaderScript) {
    throw new Error('*** Error: unknown script element' + scriptId);
  }
  shaderSource = shaderScript.text;

  if (!optShaderType) {
    if (shaderScript.type === 'x-shader/x-vertex') {
      shaderType = gl.VERTEX_SHADER;
    } else if (shaderScript.type === 'x-shader/x-fragment') {
      shaderType = gl.FRAGMENT_SHADER;
    } else if (
      shaderType !== gl.VERTEX_SHADER &&
      shaderType !== gl.FRAGMENT_SHADER
    ) {
      throw new Error('*** Error: unknown shader type');
    }
  }

  return loadShader(
    gl,
    shaderSource,
    optShaderType || shaderType,
    optErrorCallback
  );
}
Loads a shader from a script tag.
@param {!WebGLContext} gl The WebGLContext to use.
@param {string} scriptId The id of the script tag.
@param {number} optShaderType The type of shader. If not passed in it will
    be derived from the type of the script tag.
@param {function(string): void) optErrorCallback callback for errors.
@return {!WebGLShader} The created shader.