Live data from Hacker News

A whole website in a single JavaScript file

deno.com

81–90 of 170 posts

Re: A whole website in a single JavaScript file

#82

Earlier quoted context omitted.

> Almost nobody is going to use Deno to serve a basic HTML site with less than a dozen pages, Assumes facts not in evidence. People are already building JavaScript monstrosities to serve entirely static blog content.

> monstrosities why do you have to sprinkle that snark + negativity in there? it implies a toxic role of "you are superior" and "people who use JavaScript to serve static blog content" are inferior. why can't we all just get along? especially in this tight-knit programming community that is supposed to be full of love and collaboration. in today's modern day of inclusion and emphasis on mental health, you're spreadin…

> especially in this tight-knit programming community that is supposed to be full of love and collaboration

You must be new here.

Re: A whole website in a single JavaScript file

#83

Since a bunch of people are setting up a straw-man to criticize this post for "not just serving plain HTML" I'll share my opinions on this. Almost nobody is going to use Deno to serve a basic HTML site with less than a dozen pages, they are going to use it to build a monolith application to get content from a database, or a service, then generate server-rendered pages, and also host an API from the same codebase, or…

> Setting up a monolith application means using something like Ruby-on-Rails, Django, Spring, ASP.net, or rolling your own with a Node.js backend serving a SSR front-end, or hydrating React views.

https://github.com/cheatcode/joystick

Re: A whole website in a single JavaScript file

#84
I personally find it insane to use the monstrosity in terms of loc and complexity that the v8 engine is to generate a static HTML web site. I also disagree with other JS based static site generators because of the above reasons. I strongly believe it's a bad idea to have to locally install nodejs or deno and write JavaScript to generate a few HTML pages. Also, I disagree with plain HTML because of duplication.

http://mkws.sh/ uses the standard UNIX tools to generate `HTML` pages featuring a powerful sh based templating engine https://adi.onl/pp.html. Dependencies and complexity are kept to a minimum. It does the minimum required, generate HTML pages and keep duplication low using aprox 400 SLOC.

Re: A whole website in a single JavaScript file

#85

This starts to make sense when you consider the self-flagellation of a full server-side-rendering production setup that has existed over the past decade, to the point many SPA products completely give up on SSR - or nowadays throw themselves at the walled garden of Vercel/Next.js etc to solve it for them.

The truth I learned building my own SSR JavaScript framework is that it's not that complicated, it's just made complicated.

1. Get some data from a database/source.

2. Pass that data to a template/component.

3. Convert that template/component to HTML (using the given framework's version of renderToHTML()).

4. Return the HTML to your HTTP request.

For example, here's the SSR for my framework: https://github.com/cheatcode/joystick/blob/development/node/.... It blew my mind when I wrote it because I was under the impression it would be more difficult.

Re: A whole website in a single JavaScript file

#86
If the the deno executable is roughly the same size as a popular "web browser"1 why not just distribute Javscript files and let users run them in deno. Or let users "import" them into their own scripts.

1 The one I downloaded weighs in at 85MB. That is smaller than some popular smartphone apps.

As I understand it, deno is designed to be somewhat safer than nodejs.

I can edit and compile deno much easier than I can compile a popular web browser. Some popular web browsers are not meant to be edited or compiled by users. If there are things that users dislike about these programs they are powerless to change them.

The "web browser" is created and controlled by companies in the business of user data/metadata collection and advertising. AFAIK, the people behind deno are not engaged in such practices.

The "modern" web browser has become a Trojan Horse of sorts. Instead of a program for displaying and reading HTML, it has become a vehicle by which users indiscriminantly/involuntarily run other peoples' programs, often written in Javascript, in a context where a third party, the commercially-oriented browser vendor, can quietly collect user data/metadata, mediate and manipulate user interaction.

Deno takes the Javascript interpreter out of the browser.

Re: A whole website in a single JavaScript file

#87
post #5
post #2

> rendered dynamically, just in time, at the edge, close to the user. HTML. You're serving HTML. Doesn't really matter that the server-side language is JS, PHP, or BASIC.

Aaron from Deno here. Of course it's producing HTML as an output, but the point is that you can use JSX and familiar technologies like tailwind to dynamically generate that HTML at edge vs client side. And unlike a pure static site, you can add API or form routes

Wow, a lot of misunderstanding of what Deno is and how it works in these comments! Must be frustrating for you.

I'm a huge fan of runtimes that reduce boilerplate and configuration, so that's what makes me most interested in Deno. What I'm most concerned about is that we're pushing the idea that Deno's approach to third party imports solves all the problems of npm et al. If we teach developers to think of third party and native libraries as equivalent, I think we're hiding a lot of problems rather than solving them, which could be even worse.

Re: A whole website in a single JavaScript file

#88

I don't think most of the people commenting here realize that the entire site loads just fine with Javascript disabled. Essentially this is HTML getting generated on the server. The fact that it is in Deno rather than PHP, Ruby or Python is the point of the article.

Thank you. Being unfamiliar with Deno, I was trying to figure out what was loading the libraries when there was only one request/response over the wire. I of course was making the assumption that the single JS file was being run in the browser, not on the server.

I was doing the same!

Re: A whole website in a single JavaScript file

#89
post #42

I mean, this is a "single file website" in the sense that ` " rel="nofollow">https://google.com"> ` is a "search engine implementation in one line of code". The only semi-interesting thing here is that this demo pulls dependencies from 3rd party registries via HTTP without an explicit install step. It's really not that different than doing regular Node.js development with a committed node_modules (hi, Google), except…

>The only semi-interesting thing here is that this demo pulls dependencies from 3rd party registries via HTTP without an explicit install step.

We used to call those script tags back in the olden days...

Re: A whole website in a single JavaScript file

#90
post #56

Earlier quoted context omitted.

I wouldnt say an iframe and this are in any way shape or form comparable. this is a "full-fledged" website. > except that if node.land or crux.land go down, you've lost your reproducibility. Dependencies are cached. This is no different from if npm would go down. > The only semi-interesting thing here is that this demo pulls dependencies from 3rd party registries via HTTP without an explicit install step Given that t…

Yes, I know what Deno is, and when I say "semi-interesting", I mean I'm trying to find a silver lining to praise Deno for. To clarify, the similarity is that this claims to be a "single file" thing by importing the meat of the functionality from elsewhere. Which is not really interesting at all, because using batteries to make websites was already a thing with PHP in the 90s. Or, as I mentioned, it's not that differe…

> Committing node_modules guarantees that the app works even if the NPM registry were to implode. Try to deploy your deno thing from a cold state (e.g. maybe you're moving to a different AWS region or a different provider or whatever) while there's a deno.land outage and it will blow up

You can just move your DENO_DIR (cache) along with the rest of your code the same way you can move your node_modules folder.

See: https://deno.land/manual/linking_to_external_code

Post reply on HN