I have a external file (let's say foo.js)
function baz() {}
Then in my HTML, I import it with the script tag:
<script type="text/javascript" src="foo.js"></script>
I want to be able to get a string of the JS from inside of the script tag. I have tried jquery's html(), and the innerHTML and innerText attributes, but they all return empty strings.
Note: I am trying to avoid AJAX, because my server is slow, and to decrease the size of the webpage, even with caches.
Edit: The string I want to get would contain the data in the javascript file, not its URL:
getJsData(document.querySelector('script[src="foo.js"]')) == 'function baz() {}'