3

How can I check if website is loading, for example, jquery, or downloading an image from imgur? I can inspect this traffic in Firefox/Chrome, but I would like to have a programmatic way of doing so, preferably in bash.

I know I can curl the contents, but sometimes some external stuff loads all kinds of things and I want to check which content/script/resource did go through.

Like this

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
VPL
  • 31
  • 2
  • To do that properly you need to mimic the behavior of a browser to account for resources loaded via script, see [headless internet browser?](https://stackoverflow.com/questions/814757/headless-internet-browser) – Alex K. Mar 19 '18 at 17:55

1 Answers1

0

In the case of external libraries like jQuery in your example, you can check for the existence of global variables found only in that library:

if (jQuery) {
    // this resource has been loaded
}

or

if (someLibraryVariable === 'undefined') {
    // if this is undefined, this resource using this variable is not loaded on the page
}

If jQuery, or whatever your test variable is, has not been loaded to the page, this will throw an error.

You could also read the src of any script tags. In the case of images, you'd have to read the src of image tags.

travelsize
  • 74
  • 1
  • 4