# Dashboard and Widget JavaScript Extensions
Sisense has a built-in JavaScript editor for Widgets and Dashboards.
When code is added to a dashboard/widget via this editor, it is stored with that specific dashboard/widget instance and executed every time that instance is loaded in the UI.
# Adding Custom JavaScript to a Dashboard
Enhance Dashboard functionality by adding JavaScript to it in the Sisense web app.
- Click the Dashboard menu button in the top-right corner of the Dashboard and select Edit Script
- In the JavaScript editor that opens, you can add and edit your JavaScript code
- Click Save and refresh your dashboard
The scope in which this code will be executed is injected with a variable called dashboard
which provides access to the dashboard instance.
// Dashboard script that prints the dashboard title to console
console.log(dashboard.title);
See the Dashboard Class Reference for more details.
# Adding Custom JavaScript to a Widget
Enhance widget functionality by adding JavaScript to it in the Sisense web app.
- Hover over the top-right of the widget and click the pencil icon to edit the widget
- Click the Widget menu button in the top-right corner of the widget and select Edit Script
- In the JavaScript editor that opens, you can add and edit your JavaScript code
- Click Save and refresh your dashboard
The scope in which this code will be executed is injected with a variable called widget
which provides access to the widget instance.
// widget script that prints the widget title to console
console.log(widget.title);
See the Widget Class Reference for more details.