Ask HN: Deliver application as single HTML/JS file?
I’m planning to develop some simple tools for my company’s internal use, and due to IT requirements, I’m hoping to have everything run in the browser and be delivered as a single file containing HTML/JS/CSS. Is there a particular name for this practice/development style?
5 comments
[ 9.6 ms ] story [ 18.0 ms ] threadIt is usually better to separate CSS and JS into files to get the benefits of the browser’s cache or the CDN. But of course you have your particular constraints.
Added: please note that browsers tend to not cache index.html by default, so your single-file site will be re-downloaded on every access. You can <meta cache-control> it in <head>, but then you’ll have a problem with updates, because all browsers out there will ignore the origin and use the cached version until it expires.
The question I have is why do you have to distribute it as a single file?
I’m not trying to build anything huge; mostly just a few utilities with some buttons and text input forms that spit out XML files, for instance.
Being able to send people a URL is a lot easier than having to mail them a huge HTML file with everything embedded, even if you could theoretically do that with like data URLs and base 64 encoded images and whatnot. It's just not necessary and will make your project more complicated. And updates will be very hard to manage.
There's a whole industry built around web apps because they are easy to deliver to anyone with a browser. You don't have to reinvent the wheel here.