Home >Web Front-end >JS Tutorial >How Can I Reference the Currently Executing Script Tag in JavaScript?

How Can I Reference the Currently Executing Script Tag in JavaScript?

Susan Sarandon
Susan SarandonOriginal
2024-12-15 01:15:12956browse

How Can I Reference the Currently Executing Script Tag in JavaScript?

How to Reference the Currently Executing Script Tag

When you need to dynamically load scripts without having to reference the HEAD tag, the issue arises: how to reference the current script that loaded the JavaScript you're running? Here are several methods to accomplish this:

1. Document.currentScript:

This property returns the