File size: 1,393 Bytes
3883c60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Custom javascript

## What is it for?
If you want to add new features to the webui on the browser side. You can use javascript for that.

All javascript scripts are module scripts, so they can use `import`.

## How to use custom javascript
2 different descriptions below, same structure, pick the one you understand best.  
File placement:
<details>
<summary>
As markdown list
</summary>

* extension
  * extension.py
  * main.py
  * requirements.py
  * style.py
  * scripts
    * **script.js** <--
</details>

<details>
<summary>
As file path list
</summary>

extension/extension.py  
extension/main.py  
extension/requirements.py  
extension/style.py  
extension/scripts/**script.js** <--
</details>

```js
alert('Javascript from plugin!');
```

## Multiple scripts
extension/scripts/script.js
```js
// Regular import
import {alertFromImport} from './example.js'; // Make sure you include `.js`
alertFromImport();

// Import as different name
import {alertFromImport as importAlert} from './example.js';
importAlert();
```

extension/scripts/example.js
```js
// Using export declaration
export function alertFromImport() {
    alert('Javascript from import!');
}

// Using export list
function alertFromImport() {
    alert('Javascript from import!');
}

// Now export like
export {alertFromImport};
// Alternatively export with different name
export {alertFromImport as importAlert};
```