Document: beforescriptexecute event
{{APIRef}}
{{non-standard_header}}
{{deprecated_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.
addEventListener("beforescriptexecute", (event) => { })
onbeforescriptexecute = (event) => { }
Event type
A generic {{domxref("Event")}}
.
Examples
function starting(e) {
logMessage(`Starting script with ID: ${e.target.id}`);
}
document.addEventListener("beforescriptexecute", starting, true);
// or
document.onbeforescriptexecute = starting;
Specifications
Not part of any specification.
Browser compatibility
{{Compat}}
See also
{{domxref("Document.afterscriptexecute_event", "afterscriptexecute")}}
event ofDocument
{{domxref("Document.currentScript")}}