cyracrimes
cyracrimes
DDeno
Created by Zidan on 8/10/2023 in #help
Serving multiple static files to an HTTP request
Well, I guess it's often necessary hacks. I don't think this particular thing is worth doing in this particular case
37 replies
DDeno
Created by Zidan on 8/10/2023 in #help
Serving multiple static files to an HTTP request
I fully agree that you can do this, I just think it's an unnecessary hack in this case. In fairness of course, much of the technology that makes the modern web work could be described this way :P
37 replies
DDeno
Created by Zidan on 8/10/2023 in #help
Serving multiple static files to an HTTP request
That sounds fine to me :) If you run into something like this again where you really do want to avoid many individual imports, especially if they're nested, I'd encourage you to look into module bundling with tools like webpack
37 replies
DDeno
Created by Zidan on 8/10/2023 in #help
Serving multiple static files to an HTTP request
Both ideas won't work easily because you want the browser to load the files as scripts and stylesheets. They would be potential solutions if the files were just used programmatically by your app, but you're importing them, which is different. You also can't send multiple "responses" per request as far as HTTP is concerned. But: Browsers are good at doing requests. Importing multiple things at the same time isn't generally less efficient than importing only one thing, unless your logic blocks the loading of some of the resources until others are loaded
37 replies
DDeno
Created by Zidan on 8/10/2023 in #help
Serving multiple static files to an HTTP request
It sounds like you're already doing the right thing. Putting the files into some kind of zip/json package wouldn't work well here because you'd need to pile on a couple of additional hacks to then still be able to actually import the scripts/stylesheets. Importing the resources individually isn't necessarily harmful at all - is your question motivated by a measured performance issue? Have you maybe looked into bundling your application in a build step using something like webpack?
37 replies