Leahcim Leahcim - 27 days ago 9
HTML Question

are assets for all pages of multipage website fetched at once

Imagine a website with four distinct pages, and images on three of the pages, with a homepage with no images.

Will the images on the three pages be downloaded immediately when a user navigates to the homepage, or only the assets required for the homepage?

Context
The context for this question is the following. I want to know if it will improve load times to have a lightweight homepage and maybe avoid unnecessary download of assets if the user doesn't need/want to see the content on one of the other pages. (If all the content was organized into a single page app, then all of the assets would obviously download when user navigates to homepage). So is this a potential reason to choose a multi-page design

Answer Source

Will the images on the three pages be downloaded immediately when a user navigates to the homepage, or only the assets required for the homepage?

If this is not a Single Page App, then the browser has no idea about assets on the other pages of the site, until you navigate to those pages.

If all the content was organized into a single page app, then all of the assets would obviously download when user navigates to homepage.

Not necessarily - this depends upon how your Single Page App is coded. If your assets aren't exposed to the DOM on load, they won't download yet. For example, if you create a new <div> with an image inside it after clicking on an element, and that image is not used anywhere else, that image will download at that time (not on page load).

But if you're just talking about having a long homepage and referring to it as a Single Page App, then yes, everything would download on load unless you implement some type of lazy loading.