I was wondering what would be faster: Loading Static Files vs. Sending everything (including static files) in one HTML file?

For example if I had a page that needs:

  • jQuery
  • font awesome
  • CSS

I could:

  • add links to the scripts and CSS files
  • or add all of theses things in one HTML document

Which would be more efficient for me to serve from a web server?


It depends how many pages each of your visitors sees.

I have a a currency conversion site where almost all the users view exactly one page. They land a currency calculator that is specific to the two currencies they want to convert. After performing their calculation, they leave the site. To optimize the site performance, the entire page is one request. I inline the JavaScript, CSS, and even images using data URI.

This drastically improves the performance of the first page of a users session. It gets it down from 800ms to 400ms because there isn't any waiting around for additional resources.

On the other hand, when everything is inline, all the resources have to be served on every page view. If you have large JS, CSS, and images; you don't want to have to keep resending as the visitor views more pages. In that case it is a good idea to make the first page load slightly slower in exchange for faster subsequent page load times.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.