Live data from Hacker News

Entire website in a single HTML file

css-tricks.com

31–40 of 333 posts

Re: Entire website in a single HTML file

#31

Earlier quoted context omitted.

You're describing PDF files, but unfortunately Adobe didn't invest much time or money into making them interactive with a scripting language.

PDF has a limitation: it defines page size and the layout of everything fixed to this page, and thus can't do responsive layout like HTML can (reorganizing stuff in the page to match the screen size)

I wouldn't call that a limitation. In fact that is one of the major selling points of the PDF format. The document looks as intended* by the creator on all platforms whether display or print media.

* Yes, I know, PDF doesn't -always- do this, but a well designed PDF generally does.

Re: Entire website in a single HTML file

#32
post #27
post #19

Earlier quoted context omitted.

No, not a SPA. There is a concept of a single file app (SFA). You can share an html file, and that is the application. It can have inlined micro js/css frameworks, or hand-rolled everything. An SFA should be human readable though- viewing the page source is useful. I think it’s a concept worth exploring.

But what is the benefit?

less Co2 emissions

Re: Entire website in a single HTML file

#34
post #11

Using url fragments seems to limit how well Google can index it. site:john-doe.neocities.org in a google search only finds the main page and dist page.

This is like a chicken and an egg problem. Google likely haven't designed their indexer to handle pages like this because not many people do it. Many people don't do it, because Google won't index it properly.

I did find an old post from Google that suggests adding a ! after the #.

https://developers.google.com/search/blog/2009/10/proposal-f...

No idea if that still works.

Re: Entire website in a single HTML file

#35
post #31

Earlier quoted context omitted.

PDF has a limitation: it defines page size and the layout of everything fixed to this page, and thus can't do responsive layout like HTML can (reorganizing stuff in the page to match the screen size)

I wouldn't call that a limitation. In fact that is one of the major selling points of the PDF format. The document looks as intended* by the creator on all platforms whether display or print media. * Yes, I know, PDF doesn't -always- do this, but a well designed PDF generally does.

It is a limitation. Anyone who's ever tried to read a PDF journal article on their phone has experienced it. (and don't even get me started on Unicode copy/paste...)

HTML can be styled in a fixed layout if desired, and reflowed by a reader mode if needed. PDF can't be styled in a responsive way, and there's no (easily accessible) reader mode equivalent for PDFs.

HTML is a far better document format than PDF.

Re: Entire website in a single HTML file

#37
post #8

This is something I've always wanted for virtual textbooks. A single .html file with all the JS, CSS, images as inline data blobs, etc. For most physics, math, CS, etc books, this should be possible. It would make it trivial to download the book for offline use and share it with others. Other than the raster images, the entire content of these types of books would probably fit in a couple MB of text. The use of #anch…

MHT did this 20 years ago and got all but abandoned (probably for good reasons).

Interestingly, the support for mht/multipart is still there in Chrome and Firefox; or at least it was relatively recently. However it only works for files and not when accessing an mht file over http. The format itself is relatively simple.

Re: Entire website in a single HTML file

#38
post #31

Earlier quoted context omitted.

PDF has a limitation: it defines page size and the layout of everything fixed to this page, and thus can't do responsive layout like HTML can (reorganizing stuff in the page to match the screen size)

I wouldn't call that a limitation. In fact that is one of the major selling points of the PDF format. The document looks as intended* by the creator on all platforms whether display or print media. * Yes, I know, PDF doesn't -always- do this, but a well designed PDF generally does.

True, but the rigid layout is what makes PDF unsuitable for some use cases. It’s main use is to represent a printed page of a very specific size. Anything outside that just requires too much flexibility.

Re: Entire website in a single HTML file

#39

The trick is kinda meh I feel. Yes you can make a pretty cool app in a single HTML file with some inline JavaScript to boot. Still possible today just ever more out of fashion

No JS here though, just CSS using :target. That's pretty cool if you don't want a JS dependency but want more control over interactivity and presentation.

Re: Entire website in a single HTML file

#40
post #5

Normal websites used to be one file way back in the day. It was a "pro tip" to split out the JS & CSS into a separate files.

Put your script tags at the bottom of the html page so that when the JavaScript is executed all the dom elements on the page can be referenced. Either that or bootstrap in a window onload callback. I remember picking up and being in awe of secrets of the JavaScript ninja
Post reply on HN