DEV Community

Discussion on: [RANT] Why the hell does everything cool in JavaScript have to be locked behind needing server?

Collapse
 
ecyrbe profile image
ecyrbe

Let me rephrase this. I don't mean to be rude. No harm ahead.

First, Javascript is not tied to web browser technology. Like i said, Javascript can be used outside of browsers :

Now regarding document.cookie. It's specifially tied to web. It's not a browser technology, It's a web technology tied to HTTP protocol .
Cookies are fondamentally tied to remote servers. It's not your browser fault if is preventing you from using it on a file. it makes no sense to have cookies on files (imagine, this would mean having tied cookies for each file you browse on the web). No cookies are tied to a remote domain. It's their definition.

Now regarding localstorage. It's the same reason, localStorage by design are tied to a domain, not a file. Again, tying it to a file would make it useless for the web.

Now regarding doing cool things on browser without a server to share something between pages... i have your back.
Go here, this is called WebRTC. One cool thing with this. You don't need a web server. You can make two HTML files communicate with javascript.

Now have fun.

Thread Thread
 
baenencalin profile image
Calin Baenen

Let me rephrase this. I don't mean to be rude. No harm ahead.

I didn't think you intended to originally.

Thread Thread
 
baenencalin profile image
Calin Baenen

Can WebRTC hold data even when the browser is closed?
That's part of the functionality I was after when trying to see if I could use cookies or localStorage.

Thread Thread
 
ecyrbe profile image
ecyrbe

Unfortunately, no. There is no storage you can use on a browser without attaching it to a domain and then to a server.
The only thing you can do, is having a local html file that interact with a third party service that will store it for you, like aws dynamoDB. But if you really want your page to not need internet access, i'm affraid you can't.

Thread Thread
 
baenencalin profile image
Calin Baenen

Thanks for your help.

But as a subrant, that's stupid.
There should be like directoryStorage, which is like localStorage for the CWD of the HTML file.

Thread Thread
 
baenencalin profile image
Calin Baenen

I just þought:
Could I do some Stop'N'Swap shit to store data? Basically open a new tab, sync local-storages, close first tab to simulate data transfer?
Or is ðat no good?