3 ms·
Ask HN: Should I inline all JavaScript and CSS into index.html in my mobile first SPA?
I assume the fewer separate files are loaded by the mobile device the faster the loading times and even battery drain, am I right? Is this true for desktop as well? Are there any disadvantages to this approach?
- nowprovision 11y agoI don't think it's ever best practice to inline significant amounts of javascript (aside from bootstrapping code). Inlining CSS might be viable based on some recent HN articles, but a SPA generally has a non-trivial amount of javascript code and dependencies thus I can only forsee disadvantages even if you make the inlining part of your gulp/grunt workflow. You can add long-live cache directives to your javascript sources and bust them with a checksum/date/revision e.g. ?v=abc123def I suspect battery drain would be a bigger concern during the SPA running time, is it polling, does it use requestAnimationFrame for rendering, is it doing a non trivial amount of work client-side etc..
- dandare 11y agoCAn you be more specific on what disadvantages you mean when you talk about javascript code and dependencies?
- brudgers 11y agoShip. Good luck.
- brudgers 11y agoShip. Good luck.