Triggering of HTTP request

Viewed 199

HTML:

<div style="display: none";><img src="mypic.jpg" alt="Photo"></div>

Does the HTML above trigger a http request when the page first loads?

1 Answers

Yes. Specifically, <img src="example.jpg"> triggers an HTTP GET request to retrieve the content located at example.jpg. If the URL is relative (such as example.jpg, /example.jpg, or ../example.jpg), it is resolved relative to the current page.

You can view HTTP requests in browser developer tools. For example, in Chrome:

  1. Ctrl+Shift+J to open dev tools (Mac: Command+Option+J).
  2. Navigate to the "Network" tab.
  3. Reload the page (F5) to see all the HTTP requests made on page load.
Related