3 examples of 'document.currentscript' in JavaScript

Every line of 'document.currentscript' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
156function removeCurrentScript(doc) {
157 var scripts = doc.getElementsByTagName("script");
158 var lastScript = scripts[scripts.length-1];
159 lastScript.parentNode.removeChild(lastScript);
160}
80export function getCurrentScript() {
81 const scripts = document.getElementsByTagName('script');
82 return scripts[scripts.length - 1] || null;
83}
1export function currentScript() {
2 return document.currentScript || document._currentScript || getCurrentScriptTheHardWay();
3}

Related snippets