code: def add_js_lib(html, embed_js=True):
      """Add javascript libraries to html template.
  
      If embed_js is True, jquery and plotly are embedded in resulting page.
      otherwise, they are loaded via CDNs.
  
      """
      js_dir = os.path.join(os.path.dirname(__file__), "data", "js")
      with open(os.path.join(js_dir, "surface-plot-utils.js")) as f:
          js_utils = f.read()
      if not embed_js:
          js_lib = f"""
          <script
          src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js">
          </script>
          <script src="https://cdn.plot.ly/plotly-gl3d-latest.min.js"></script>
          <script>
          {js_utils}
          </script>
          """
      else:
          with open(os.path.join(js_dir, "jquery.min.js")) as f:
              jquery = f.read()
          with open(
              os.path.join(js_dir, "plotly-gl3d-latest.min.js")
          ) as f:
              plotly = f.read()
          js_lib = f"""
          <script>{jquery}</script>
          <script>{plotly}</script>
          <script>
          {js_utils}
          </script>
          """
      if not isinstance(html, Template):
          html = Template(html)
      return html.safe_substitute({"INSERT_JS_LIBRARIES_HERE": js_lib})
  
file_path: nilearn/nilearn/plotting/js_plotting_utils.py
imports: import base64
  import os
  import warnings
  from string import Template
  import matplotlib
  import matplotlib.pyplot
  import numpy
  from nilearn.plotting.html_document import HTMLDocument, set_max_img_views_before_warning
  from ..None import surface
  from .._utils.extmath import fast_abs_percentile
  from .._utils.param_validation import check_threshold
label_desc: Use image node_id 1 for calling a global function with example usage: add_js_lib(html, embed_js) and returns: html