Getting content of <script> tag

html, javascript, jquery

Solution

What about this.

$.get("/something.js",function(scriptContent){alert(scriptContent)});

It will pull the content through an ajax request

Alternatively, you can pull the content on the server and return it back to the client by making a request to a page that facilitates the loading of the JS file on the server. This is necessary if the js file is hosted under a different domain

Problem

I am trying to get content of `<script>` tag in html: i can get `<script>test</script>` content by using jquery `$("script").html()`. but how to get content of `<script src='something.js'></script>` ?

Original source

Related problems