Javascript
javascript(from_string=None, *, from_file=None)
¶
Utility class to handle JavaScript injection for interactive plots.
This class provides multiple ways to load JavaScript: directly from a
string or from a JavaScript file. It is intended to be combined with
interactive().
WARNING
JavaScript added through this class is executed directly in the generated HTML page. Only use code from sources you trust. Running untrusted JavaScript may expose sensitive data or execute malicious actions in the user's browser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
from_string
|
Optional[str]
|
JavaScript code as a string. |
None
|
from_file
|
Optional[Pathish]
|
Path to a JavaScript file. |
None
|
from ninejs import interactive, javascript, save
(
interactive(p)
+ javascript("console.log('hello world')")
+ javascript(from_file="script.js")
+ save("output.html")
)