code: def test_scri002_scripts_on_request(dash_duo):
      app = Dash(__name__, eager_loading=False)
      app.layout = html.Div(id="div", children=[html.Button(id="btn")])
  
      @app.callback(
          Output("div", "children"), [Input("btn", "n_clicks")]
      )
      def load_chart(n_clicks):
          if n_clicks is None:
              raise PreventUpdate
  
          return dcc.Graph(
              id="output", figure={"data": [{"y": [3, 1, 2]}]}
          )
  
      dash_duo.start_server(
          app,
          debug=True,
          use_reloader=False,
          use_debugger=True,
          dev_tools_hot_reload=False,
      )
  
      # Give time for the async dependency to be requested (if any)
      time.sleep(2)
  
      assert hasWindowPlotly(dash_duo) is False
  
      dash_duo.find_element("#btn").click()
  
      # Wait for the graph to appear
      dash_duo.find_element(".js-plotly-plot")
  
      assert hasWindowPlotly(dash_duo) is True
  
file_path: dash/tests/integration/test_scripts.py
imports: import time
  import pytest
  from dash import Dash, Input, Output, html, dcc
  from dash.exceptions import PreventUpdate
label_desc: Use image node_id 4 for calling a global function with example usage: test_scri002_scripts_on_request(dash_duo) and returns: dcc