JavaScript Get all loaded scripts

I am trying to create a Javascript function that will return all downloaded javascript files. For example:

I load jquery.js, jquery.somescript.js and tinymce.js

I want the function to return everything in script format (so if I saved and ran the returned text again), it will work the same as if I named the files described above. Also, if TinyMCE loads 15 JS fies, it should also return.

I hope this is not too hard to understand, but any help would be greatly appreciated!

Thank Advance

+6
javascript dynamic load
source share
2 answers

getElementsByTagName should start:

var scripts = document.getElementsByTagName('script'); // TODO: loop and read the src attribute 
+5
source share

I'm not sure exactly what you are trying to do, but it sounds like you need one .js file instead of many. I think you will do more work for yourself to do this in a script. Just browse the source for all script files and then add to one file. Save this and then call this file as your src.

+2
source share

All Articles