For instance, when I use the code below to retrieve a NodeList of all scripts on a webpage:
document.querySelectorAll('script')
Is there a method to distinguish between scripts that were part of the original HTML source and those that were added later via other scripts?
I attempted to compare the data in the properties of each node/script:
However, I have yet to identify any distinct characteristics that set apart scripts present in the HTML source from ones loaded through another script.
While I recognize that I can obtain this information using the Network tab in developer tools under the initiator column, I am interested in being able to differentiate scripts programmatically with JavaScript if feasible.
If an alternative method to
document.querySelectorAll('script')
is necessary, I am open to exploring it as well.
Thank you for your help!