code: def script_for_render_items(
      docs_json_or_id: ID | dict[ID, DocJson],
      render_items: list[RenderItem],
      app_path: str | None = None,
      absolute_url: str | None = None,
  ) -> str:
      """Render an script for Bokeh render items.
      Args:
          docs_json_or_id:
              can be None
  
          render_items (RenderItems) :
              Specific items to render from the document and where
  
          app_path (str, optional) :
  
          absolute_url (Theme, optional) :
  
      Returns:
          str
      """
      if isinstance(docs_json_or_id, str):
          docs_json = f"document.getElementById('{docs_json_or_id}').textContent"
      else:
          # XXX: encodes &, <, > and ', but not ". This is because " is used a lot in JSON,
          # and encoding it would significantly increase size of generated files. Doing so
          # is safe, because " in strings was already encoded by JSON, and the semi-encoded
          # JSON string is included in JavaScript in single quotes.
          docs_json = serialize_json(
              docs_json_or_id, pretty=False
          )  # JSON string
          docs_json = escape(docs_json, quote=False)  # make HTML-safe
          docs_json = docs_json.replace(
              "'", "&#x27;"
          )  # remove single quotes
          docs_json = docs_json.replace(
              "\\", "\\\\"
          )  # double encode escapes
          docs_json = "'" + docs_json + "'"  # JS string
  
      js = DOC_JS.render(
          docs_json=docs_json,
          render_items=serialize_json(
              [item.to_json() for item in render_items], pretty=False
          ),
          app_path=app_path,
          absolute_url=absolute_url,
      )
  
      if not settings.dev:
          js = wrap_in_safely(js)
  
      return wrap_in_onload(js)
  
file_path: bokeh/src/bokeh/embed/elements.py
imports: from __future__ import annotations
  import logging
  from html import escape
  from typing import TYPE_CHECKING, Any
  from ..core.json_encoder import serialize_json
  from ..core.templates import DOC_JS, FILE, MACROS, PLOT_DIV, get_env
  from ..document.document import DEFAULT_TITLE
  from ..settings import settings
  from ..util.serialization import make_globally_unique_css_safe_id
  from .util import RenderItem
  from .wrappers import wrap_in_onload, wrap_in_safely, wrap_in_script_tag
label_desc: Use image node_id 3 for calling a global function with example usage: script_for_render_items(docs_json_or_id, render_items, app_path, absolute_url) and returns: wrap_in_onload