-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
54 lines (36 loc) · 1.28 KB
/
index.md
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
---
title: "Document: beforescriptexecute event"
short-title: beforescriptexecute
slug: Web/API/Document/beforescriptexecute_event
page-type: web-api-event
status:
- non-standard
browser-compat: api.Document.beforescriptexecute_event
---
{{APIRef}}{{non-standard_header}}
The `beforescriptexecute` event fires when a static {{HTMLElement("script")}} is about to start executing. It does not fire if the element is added dynamically, such as with {{domxref("Node.appendChild()", "appendChild()")}}.
## Syntax
Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property.
```js
addEventListener("beforescriptexecute", (event) => {});
onbeforescriptexecute = (event) => {};
```
## Event type
A generic {{domxref("Event")}}.
## Examples
```js
function starting(e) {
logMessage(`Starting script with ID: ${e.target.id}`);
}
document.addEventListener("beforescriptexecute", starting, true);
// or
document.onbeforescriptexecute = starting;
```
[View Live Example](https://mdn.dev/archives/media/samples/html/currentScript.html)
## Specifications
Not part of any specification.
## Browser compatibility
{{Compat}}
## See also
- {{domxref("Document.afterscriptexecute_event")}}
- {{domxref("Document.currentScript")}}