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
this disclaimer
156function removeCurrentScript(doc) {
157 var scripts = doc.getElementsByTagName("script");
158 var lastScript = scripts[scripts.length-1];
159 lastScript.parentNode.removeChild(lastScript);
160}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

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