r/webdev • u/Ronin-s_Spirit • 20h ago
Question Is it worth bundling HTTP requests?
I am making a web server for a site and I need experienced server devs or browser experts to answer this question. My goal is to load the site as fast as possible. Every page has a "main" script that may need a number of "components", I could solve components in 2 ways: 1) write a bunch of individual `modulepreload` tags; 2) write a unique URL `modulepreload`.
Solution 1 is going to be 5, 10, 20 individual HTTP round trips.
Solution 2 will always be just one request, but there will be many unique URLs across the site, which hurts caching.
To clarify, the server itself doesn't matter - it has no work besides immediately sending back a file. I just can't pick a solution, considering my lack of expertise. I haven't measured actual performance of either solution because I kind of can't right now.
Solution:
I will go with individual modulepreload tags considering modern HTTP multiplexing, and cache benefits.