Show HN: Plain Vanilla – a tutorial website for vanilla web development
plainvanillaweb.com
Show HN: Plain Vanilla – a tutorial website for vanilla web development
1–10 of 19 posts
Re: Show HN: Plain Vanilla – a tutorial website for vanilla web development
#2I disagree with your statement: "Don't use the plain vanilla approach until you've tried some of the popular web development frameworks and have learned why you might want to do without, and until you're confident on how to structure a codebase without the help of a framework."
I was writing vanilla javascript for years before I began using frameworks, so when I encounter a new one, I understand exactly what problem it's trying to solve. For any beginners, I personally recommend just building websites directly, without any framework assistance.
Re: Show HN: Plain Vanilla – a tutorial website for vanilla web development
#3I've written all of that from scratch because I got tired of maintaining node.js
But when splitting up the js file into pieces and using es6 modules, say 12 different files, Chrome makes 8 TCP connections on 8 different sockets, and each connection has its own TCP handshake (and TLS handshake for https). How do you bundle things without using a build system or a bundler? Import maps help, and it's not difficult to simply hash the page and copy the asset to a "dist/" folder with the hash appended, but it's still slow on first page load.
I'm not a web developer professionally (or network engineer), so I'm learning about web networking myself for the first time. It might be helpful to add a section about "traffic shaping"? I've smacked together a service worker that does the work of caching well-enough for now, but I'm definitely doing something rather strange and reinventing something. My page loaded significantly faster when it was just 1 JS file, no caching needed.
Re: Show HN: Plain Vanilla – a tutorial website for vanilla web development
#4Re: Show HN: Plain Vanilla – a tutorial website for vanilla web development
#5I've actually been struggling with a problem related to this. First time page loads if you have a 2000loc JavaScript file + index + css + favicon requests nothing but those 4 resources, which is very quick on a keep-alive http 1.1 server. I've written all of that from scratch because I got tired of maintaining node.js But when splitting up the js file into pieces and using es6 modules, say 12 different files, Chrome…
It sounds like preloading modules would help your case a lot: https://web.dev/articles/modulepreload
The number of connections is a bit of a red herring here, the problem is (typically) that the browser loads one module which then tells it to load another module, and so on. Each round-trip is wasted time. Preloading gives the browser a flat list of all required dependencies right away. By the way, this applies to everything else: having all required resources declared at the top of the page makes things faster. You can even preload some less-obvious things like background images referenced by CSS files.
This might achieve the "bundling" you want, in the sense that all the preloaded resources can be multiplexed into a single connection. But again, the number of connections is almost nothing compared to the number of round-trips required.
Re: Show HN: Plain Vanilla – a tutorial website for vanilla web development
#6I've actually been struggling with a problem related to this. First time page loads if you have a 2000loc JavaScript file + index + css + favicon requests nothing but those 4 resources, which is very quick on a keep-alive http 1.1 server. I've written all of that from scratch because I got tired of maintaining node.js But when splitting up the js file into pieces and using es6 modules, say 12 different files, Chrome…
If you allow UDP connections in your firewall, it will upgrade to HTTP 3 automagically as well.
I highly recommend it
Re: Show HN: Plain Vanilla – a tutorial website for vanilla web development
#7[0] https://caniuse.com/?search=web%20components [1] https://stackoverflow.com/a/11487293/691156
Re: Show HN: Plain Vanilla – a tutorial website for vanilla web development
#8Re: Show HN: Plain Vanilla – a tutorial website for vanilla web development
#9Nice work, I haven't tried web components but support is better than I expected per caniuse[0]. This weirdly reminded me of a time 12 years ago[1] when I was encouraged to avoid using the term "vanilla" as it sounds like another framework [0] https://caniuse.com/?search=web%20components [1] https://stackoverflow.com/a/11487293/691156
It is a framework, but just vanilla :)
Re: Show HN: Plain Vanilla – a tutorial website for vanilla web development
#10But the browser evolves:
- Convenient and flexible browser APIs totally replaced jQuery
- HTTP2 HPACK, multiplexing and connection coalescing make SPA and bundlers unnecessary
- Web Component and Shadow DOMs helps you write modular HTML and CSS
etc etc
And developer needs to evolve, too! These frameworks make too many leaky abstractions that developers should think about. It turns out if they don't encounter problems at the beginning, they will meet them later with interest.
I was going to write a similar document, but thankfully you write it so well!
P.S. I'm also not against the framework to solve engineering problems like testing or CI/CD.