Hacker News new | ask | show | jobs
by josefx 2323 days ago
> You can always create a barebones HTML file and drop some JS into a `<script>` tag and be up-and-running in two minutes

Local "file://"? That isn't even trusted, current browsers outright block simple functionality like loading other files with XmlHttpRequest by default. You either have to completely disable various security settings or spin up a simple http server. At least I think that http is still enough for localhost, with the push for https you might want to set up a LetsEncrypt cert before you even think about starting a JS Hello World.

2 comments

Not to put too fine a point on it, but is

> loading other files with XmlHttpRequest

simple functionality? To me that actually does sound kind of like an 'advanced' thing to even think of from a beginner's perspective... i.e. someone who's just trying to learn to make a web page with perhaps a little bit of interaction.

(But then, maybe my idea of a beginner's level of ambition is hopelessly old-fashioned, I don't know.)

I do think that it would be great if there were a way to tell a web browser through its Dev-thingy to actually serve a folder to itself as if it were served by a bona-fide web server with HTTPS. I mean, it's not that hard to start a python-http-module-server, or install the npm module 'http-server' (or whatever it's called), but y'know...

EDIT: I don't necessarily disagree with you, but I think it may be a matter of degree.

> I do think that it would be great if there were a way to tell a web browser through its Dev-thingy to actually serve a folder to itself as if it were served by a bona-fide web server with HTTPS.

I'd like to plug Beaker Browser as an amazing tool for getting started with barebones HTML, CSS, and JS. I would say Beaker marvelously fulfills this wish for a browser to serve a folder to itself.

https://beakerbrowser.com/

Because it is built around the peer-to-peer dat:// protocol, it also ends up being "local-first" regarding web pages that you write with it (as well as sites that you decide to seed).

@staltz has an interesting presentation on the utility of Beaker Browser: https://staltz.com/beaker-frontend-dev-dream-browser/#0

On the other hand, I don't know enough to speak to Beaker's capabilities with XmlHttpRequest.

When I was a teenager learning how the web works I used the free version for MAMP for this. It was super straightforward, as I recall. Open it up, choose a folder, and serve. I think it even included PHP.
i share your frustrations, especially as a retro and nojs fan.

today, for now, it's still mostly workable, with some fiddling, and yes, setting up a local web server.