var scripts = document.getElementsByTagName("script"); for (var i = 0; i < scripts.length; i++) { if (scripts[i].src) { console.log(i, scripts[i].src); } else { console.log(i, scripts[i].innerHTML); } }