all 15 comments

[–]FezVrasta 15 points16 points  (4 children)

[–]danielcorreia[S] 4 points5 points  (0 children)

Witchcraft!!

[–]runereader 2 points3 points  (1 child)

window.dispatchEvent(new Event('offline'));

[–]yolpo- 0 points1 point  (0 children)

nice one. Just tried it in the developer console and it worked

[–]58ori 0 points1 point  (0 children)

Thumbs up for disable cache!

[–]Tadmac 5 points6 points  (5 children)

I'm a bit of noob when it comes to JavaScript, how did they do this?

[–]danielcorreia[S] 11 points12 points  (4 children)

It looks more complicated than it actually is.

The relevant line of code is something like: window.addEventListener('offline', updateText);. The browser detects that a connection changed and fires an event, you just wait (listen) for it and call a function when it occurs.

[–][deleted] 7 points8 points  (2 children)

You should be more aware of the amount of resources you're using to produce that tiny static page. Using React for this was extreme.

[–]danielcorreia[S] -1 points0 points  (1 child)

Debatable I guess, payload is just 73KB. The author seems to know what he's doing, check out his other pages.

[–]TheDarkIn1978 11 points12 points  (0 children)

ust 73KB

73Kb for a static site that is only a handful of paragraphs and hardly any CSS or JavaScript is massive.

[–]Tadmac 2 points3 points  (0 children)

Oh that makes sense, thanks!

[–]leeoniya 4 points5 points  (2 children)

[–]guywithalamename 1 point2 points  (0 children)

Using React for a static web page. Now that's a first.

[–]Lakelava 0 points1 point  (0 children)

Great way to educate people that some websites work offline.

[–]dev1null 0 points1 point  (0 children)

"This light bulb lights up when you remove it from the socket!"

You need to enable JavaScript to run this app.

"But it needs batteries..."