3

I have a script include on a page as following.

<script src="https://domain/demo.js" type="text/html" id="google_script"></script>

Once the demo.js is loaded, I need to grab the content of loaded demo.js without recalling it with ajax. Please share your thoughts if that's possible and how.

Majid Parvin
  • 4,499
  • 5
  • 29
  • 47

1 Answers1

2

Sadly no.

With pure JavaScript you can't get content of other JavaScript file without executing it.

Possible solutions:

EDIT: With JavaScript you can't get full script, but function like:

var funcsourcecode = functionname.toString();
Community
  • 1
  • 1
Samuel Tulach
  • 1,319
  • 13
  • 38