Search code examples
javascriptwebbrowser-controlrequire

List javascript urls of a page


is there a way I can extract the list of all the JS imported in a page, maybe via browser console? I'm not looking for only the ones imported via , but also the ones imported by other js scripts.

So, let's say I have a page that is using requirejs, and during the usage of the page, many other JS files are loaded. How can I list these files imported URL?


Solution

  • You follow this code and get all URLs in urlsArray variables

    like this output image. result array

    var urlsArray = [];
    
    [].forEach.call( document.querySelectorAll("script[src]"), function( src ) { 
      urlsArray.push(src.src);
    });
    console.log(urlsArray);
    

    Thanks [sayed021]