Hacker News new | past | comments | ask | show | jobs | submit login
A JavaScript-Free Front End (dev.to)
484 points by bibyte 10 days ago | hide | past | web | favorite | 209 comments





It's perfectly possible to do some nifty tricks with CSS alone. The one thing this author has omitted is the impact this has on accessibility. Sure, I can open a modal without the need of JavaScript, but my focus isn't trapped within the modal and with no standard keyboard shortcut (ESC) to dismiss the modal, it provides a sub-standard experience for all users.

Be sensible and use JavaScript when it's appropriate. Please don't think it's cool to create some fancy JS-less widgets and forget about accessibility.


You can trivially add keyboard shortcuts to this solution after it's implemented - with 0 rework. Moreover, the is absolutely no guarantee that an arbitrary JS library for modal popups will have better usability. And I have yet to see one that will not fail if I block JavaScript, creating horrible user experience for everyone who does so. Funny how usability concerns go out of the window when NoScript/uBlock users are involved.

Personally, I try to avoid modal popups altogether. There is almost always better ways to structure things. The whole concept of "modal" UI doesn't map well to the "document" nature of web elements.


This is not simply about modals. Using VoiceOver and Chrome I cannot access the pop up menu to navigate the site. These CSS tricks are cool but they shouldn't be used in a production environment without basic usability testing.

More specifically, no you cannot add keyboard shortcuts "with 0 rework". How are you returning the users focus to the active element before they opened the modal? The key is not to use an "arbitrary JS library for modal popups" and to use or create a modal library that has superior usability baked in. Sure, maybe there's a superior workflow than to use a modal.

For anyone that is interested MicroModal (https://micromodal.now.sh/) ticked a lot of boxes last time I checked.


>These CSS tricks are cool but they shouldn't be used in a production environment without basic usability testing.

The same can be said about any JS library that interacts with page controls.

The wast majority of modal dialog implementations on the web do no follow the standards you're referencing. Do you routinely criticize websites on this basis, or is this criticism only reserved for ones that use vanilla HTML+CSS for core functionality?

>More specifically, no you cannot add keyboard shortcuts "with 0 rework".

Yes, you can. 0 rework != 0 work. Anything that unchecks that checkbox on Esc will close the modal. To implement that you don't need to change the structure of what you've already done. Progressive enhancement.

>How are you returning the users focus to the active element before they opened the modal?

Focus management has absolutely nothing to do with where the state of the modal is stored. You can implement all of the usability features you want on top of Checkbox + CSS solution with the added benefit of not screwing everyone who can't run your scripts or completely breaking the website for everybody if something in your JS gets broken.


> The same can be said about any JS library that interacts with page controls.

Difference being JS, if written by an averagely competent individual, can be changed once and this change will apply to any instances where it's called, and this cute pattern will need to be manually updated in any number of places where it's applied, one by one.

> Yes, you can. 0 rework != 0 work.

Rework meaning you have to go back over the "done" thing and then do more to cover the technical debt. On each and every instance of the thing.

> if something in your JS gets broken

As opposed to replacing the cute styling trickery for browsers that don't really support it, which is somehow better?


While I recognize a lot of the HN crowd blocks Javascript, the overall percentage of people doing this is absolutely tiny.

What is the case for making Javascript-blocking users a priority?


Security matters, and blocking JS blocks the majority of vulnerabilities on browsers. We should help users who want to protect themselves.

No. If I develop an interactive website, I'll be damned if I try to also keep the No-JS folks satisfied. Either you trust me, or you don't.

A reasonable argument iff you use no external libraries, or personally audit every one of them completely (including all updates). Otherwise maybe I trust you, oh random person on the internet, but should I also trust the 49 authors of the 37 libraries you're including from 4 different CDNs? (Bonus points if you run ads and let under-vetted 3rd parties inject whatever they want into the page)

But why should he put time into supporting you?

Interestingly I've had this debate with at least one person on hacker news who was complaining about how people were stealing from his website by running ad blockers, and how he'd tried to fight them but it had left his website looking broken for anyone who was running an ad blocker, so he'd had to roll it all back. Why would he do that?

The answers actually pretty simple. People who are interested enough in technology to read hacker news are both disproportionately likely to discover a new product trying to build an audience, and disproportionately likely to influence their friends either for or against that product. They're trusted by their non-technological peers.

So why support script-blocking hacker-news users? Because if your website doesn't work for them, they're gonna tell all their friends that your product doesn't work properly. When I got my first job, I was told that on average satisfied customers tell 2 friends they were satisfied, and dissatisfied customers tell 12 friends they were dissatisfied. I don't know how accurate those stats are, but I do know people complain more than they praise.

I certainly go out of my way to warn friends and family away from products that I feel are committing technical faux pas. How else will they know they're using websites made by people of limited technical capability, with all the risks that implies, if I don't tell them?


Why should I use his app?

You don't have to use his app, and he doesn't have to support users like you.

It's a two-way thing: many developers don't want to support people that switch off JavaScript, and these consumers are apparently happy that they can't access the majority of the internet (or so they say).


I think that's a slight misrepresentation; developers don't want to invest the (significant) effort to run without JS, and some end-users are unwilling to take the risks with allowing arbitrary code execution in their browser. But I doubt that developers (generally) don't want to support noscript; if it were 0 effort than I expect it would be common. And such users aren't happy that they can't access a lot of sites, they just find the tradeoffs unacceptable.

That said, aside differing biases I'm not convinced that we actually disagree.


Some "interactive" websites have to use javascript, it's true, but it always seems tragic when a site that doesn't really need to requires it anyway. Isn't there something appealing about a platform where millions of strangers can converse and publish information without needing to fully trust one another?

>Either you trust me, or you don't.

Can I sue you if your website serves me malware? Because that's the concern.


Do you vendor your javascript libraries and host them from your own domain, or do you just hotlink them from random CDN's all around the internet like everyone else?

If you're hotlinking them, I don't trust you.


One could use Subresource Integrity (https://hacks.mozilla.org/2015/09/subresource-integrity-in-f...) to mitigate the most obvious threats from CDNs. Granted, that does have some maintenance work, but if you're already managing dependency versions (and you really should) then it's minimal extra work.

Correct me if I'm wrong, but all the scripts the website owner hotloads have to also use subresource integrity for the scripts they are hotloading, or subresource integrity gains nothing beyond the first level of script loading?

I rarely feel that website owners out out to get me, my distrust comes from scripts that load scripts that load scripts. Lets not piss about, I know most people who have written websites that are loading jquery from a remote CDN haven't bothered to inspect it to see what it's loading. By contrast, a website that has vendored all it's script dependencies has looked at the entire dependency tree at least /once/. That shows a baseline level of competence that I'm willing to extend trust on top of.


You don't have to argue why you don't trust me, when I'm arguing that I'm not responsible for negative impacts in the case that you do not trust me.

Many won't and visitors will leave. New visitors will bounce more often. Users with trust for every site is low until earned.

ok, i don't.

It's not just modals. Hidden but toggled via labeled checkboxes — how are they gonna play with screen readers?

How do you properly shift focus to the dropdown menu whose visibility is toggled by clever CSS tricks?

And yes, modals may be needed sometimes especially in payment forms even if that modal is only visible to the screen reader.


> block JavaScript

How did we even get here? I remember when we used to hide javascript inside of comments to support user agents that didn't speak it.


NoScript users aren’t disabled. There is no reason to even consider people that willingly disable themselves.

Also: be sensible about accessibility when writing JavaScript SPAs. If your page consists entirely of nested <div>s without any semantic markup, you're going to have problems (and perhaps risk a lawsuit).

This can’t be true, right? A ton of major applications (Google’s for starters like GMail) have some layer of post processing or obfuscation (or maybe it’s just compiled) to their generated DOM that results in a ton of nested divs with gobbledygook classes.

It's not the DIV-soup that is an accessibility problem (though that's what often takes the blame), it's the lack of adding accessibility attributes (`aria-*, tabindex, title`, etc.). Lots of builtins, especially form elements, give you many accessibility traits "for free", but there are a wide variety of ways to tag a bowl of DIV soup for accessibility.

Then there's "semantic HTML(5)" (`<article>, <section>`, etc.), which still exists, but is not _particularly_ worthwhile for accessibility: Too much of the web lacks these tags, so most common consumers of this nature (scrapers, screen readers, content summarizers) use other, often AI-based, strategies to tag content semantics.


Ah interesting thanks for the info. I'm now wondering how accessible GMail for instance is. I'm see a lot of tabindex and aria-labelledby but the values seem to be garbage as well. But I temper that against my assumption that GMail, being such a universally used application, must have some mind towards accessibility.

Totally agree on your statement. It's not possible to build modern solutions that are accessible without using some JavaScript. It's always a matter of where you want to go. And it's easy to spare e.g. modals. The question is just if you can solve user experience issues with just HTML and CSS for all use cases.

On the other side, there are more solutions built into HTML and CSS one thinks. In your particular example, you can use the HTML dialog element and get built in keyboard and focus management (still requires a polyfill for many browsers).


Just to play devil's advocate: why use a modal in the first place instead of just opening a new page?

You haven't seen how many tabs my wife has open. If you send her to a window, she's never getting back :)

Less jarring to the user, creates the UX where the user knows their state is still there once they dismiss the modal, less commitment overhead, etc.

I find the opposite is true. I can't count the number of times I've accidentally closed a window or backed out of a page using a modal where the semantics were unclear or the comically tiny 'x' was hidden below mobile-Chrome's sliding address bar on a page that was too short to scroll.

It seems like the modal is often abused as an anti-pattern, where it's not even clear if you are still on the same page because the content is almost entirely concealed/darkened. Reddit desktop is an example. Modals with multi-page length scrolling content is just absurd

I'd reckon it's easier to share data between parent and child, than between completely different pages.

Agreed on the modals, but this is a non-unique problem. Accessibility just takes work, whether it is fixing JavaScript libraries or supplementing CSS only solutions. And since performance and accessibility often suffer together at the hand of these JavaScript libraries, it is encouraging to see that there are other options for building good user experiences.

Since I'm caching and gzipping everything, each subsequent pageview is around 6 KB; far smaller than the SPAs I've seen with equivalent functionality.

That's ace. But my internet connection has a 2 second latency so I still have to wait an annoyingly long time every time I interact with your app. My connection is terrible too, so it drops every 10th request, and now I'm seeing a lot of broken pages. If only you'd written an offline-first PWA and used background-loading and prefetching with some intelligence to retry failed requests in order to deliver content before I actually need it this would have worked so much better.

But hey, the app is perfect for you on your robust wifi, so it must work out there in the real world, right?

Snark aside, there's a good reason to build web software in a variety of different ways. Pick the one that suits your users. Don't assume everything works perfectly and every internet connection is strong, fast wifi. That just means a lot of users (especially poorer ones in rural communities) are going to struggle with what you're selling.


> But my internet connection has a 2 second latency so I still have to wait an annoyingly long time every time I interact with your app. My connection is terrible too, so it drops every 10th request, and now I'm seeing a lot of broken pages.

I often work on a train over a 4G connection, so this describes me too. I much prefer traditional style web applications over SPAs specifically because of this.

You know what happens if a request is taking too long or fails with a traditional web app? I hit reload and it retries.

You know what happens if the same thing happens with most SPAs? It throws away my unsaved data and puts me back on the starting screen.

Sometimes there's a JavaScript-powered retry I can use instead. Sometimes it works, usually it is very unreliable (if something has failed to load, often the JavaScript is having problems too).

Sure, I'm willing to accept the possibility that an SPA can be written in such a manner as to compensate for this hostile environment. It's just: I've used a lot of these apps, and I haven't found one that works reliably over a poor connection yet.


> You know what happens if the same thing happens with most SPAs? It throws away my unsaved data and puts me back on the starting screen.

This is just bad design though. Obviously the dust isn't settled on the whole html5 technology yet, but for anyone who is wondering how to make an SPA more resilient to network instability, the solutions are: axios-retry, idempoteny PATCH/PUT, service workers, basic error handling, and always have the URL represent where the user is.


>This is just bad design though. Obviously the dust isn't settled on the whole html5 technology yet, but for anyone who is wondering how to make an SPA more resilient to network instability, the solutions are: axios-retry, idempoteny PATCH/PUT, service workers, and basic error handling.

Thing is, you get proper error messages, the ability to retry, warnings if you're about to repeat an unsafe operation etc out of the box if you don't use a SPA and render things server-side. The browser does this for you.

Sure, you can do a better job. But I've lost count of the number of SPAs and JS-driven apps where connection error = infinite spinning loader icon and no feedback or ability to retry. If you're going to willingly throw away the routing you get from HTTP, the progress indicators you get from actual links and non-AJAX requests and the browser error handling you better make damn sure you implement it all again in JS and provide feature parity for the user.

It's not just HTTP either - accessibility features like keyboard navigation often aren't implemented in React components because folks only write an `onClick` handler. Sure - the devs should've loaded "eslint-plugin-jsx-a11y " and enforced rules that prevent this sloppiness on their CI - but it's far too easy to do it wrong and so devs do do it wrong and the users suffer from a poor experience as a result.


I've seen pure server based applications neglect all of those things, including destroying your input on errors, so it's not really helpful for anyone who actually needs an SPA.

Yep, how many times have you seen a web page say tell you not to refresh the page to avoid losing your progress.

so many older job applying application tend to be built in this way. Its happened way too often that I have filled in a whole page of info, from my birth to every job I have ( even though I literally have a resume just for that ), the browser crashes and I lose everything.

> so I still have to wait an annoyingly long time

> it drops every 10th request

If the app saves data to a server, that's gonna happen regardless anyways (and one could argue that techniques like optimistic updates might make the experience even worse)

Also remember that HTML can be streamed and partially rendered even if it's not fully downloaded, and the investment required to enable this is minimal. The same cannot be said about a SPA's data fetching/rendering strategies.

Having worked on bloated apps before, I despise when people throw around the word "prefetching" as if it's some sort of magic spell. At best it eats my battery and bandwidth needlessly, and at worst, it's weasel wording for slowing down time-to-first-pixel :(


I keep hearing offline-first trumpeted, but I have seen no examples of what that means.

Terrible connections exist. But I fail to see how adding more scripting will always help with that. Service workers are definitely promising, but documentation for common use cases is still lacking.

Even with a terrible connection, I would still trust a server-side app to load correctly on a refresh more than a SPA.

If anything, the minimal use of Javascript is as inclusive as a web app can be.


I think they're talking about mobile twitter, where every time I visit I see the message "something went wrong". Then I tap retry and get the same message. It's very offline first. Then I reload the whole page and get the online version.

It seems to have to do with blocking their trackers: https://news.ycombinator.com/item?id=19130667

The neat thing is, an app using Service Workers doesn't have to be an SPA. You can use a Service Worker to just cache HTML as delivered from your server. E.g. I've seen blogs having a small service worker that just cached the last 5-10 accessed articles and added a custom error page saying "sorry, you are not online right now, but you can read the following articles from cache:"

Henrik Joreteg (https://twitter.com/HenrikJoreteg) makes some pretty good arguments for PWAs. I've not had the chance to work on one, but when you start looking at mobile devices in particular, they do seem to be a good middle ground between the slimness of a document (web page) and the capability of a native mobile app. They're also not mutually exclusive with "no javascript" (if you do it right, which is a consideration). And they have the potential to save developers work, since you can get away with a PWA instead of native apps on 2+ platforms.

I'm very much on board with the promise of PWAs, but so far I've never found an approach that didn't feel too complicated/tedious. That said, I've not made serious attempts in at least a few months, maybe a year. Would you say the situation has solidified/standardized in the interim, and if so, could you point me to some resources?

Unfortunately, I'm in the same boat, having only fiddled briefly with some of the newer web APIs, rather than architecting an app around service workers. My impression comes from folks like Joreteg who do the work, and from the increasing frequency with which new native-like APIs are released into browsers (though almost invariably implemented badly).

That said, even though the way service workers are registered is sort of odd, they're pretty trivial to work with once you're there. As far as resources go, MDN is always pretty solid, and this post (https://developers.google.com/web/fundamentals/primers/servi...) on Google's web dev guides is what I used to familiarize myself with them.


> But I fail to see how adding more scripting will always help with that

Your app has no control over browser connection management. JavaScript you write is aware of idempotency and retry semantics of your app, so it can manage requests more intelligently than the browser, without disrupting the user experience.

So sure, it won't always help if you do it badly, I can see how it always helps if you do it well.


It’s great that you have an opinion about the benefits of a SPA for slow connections and other people (lower comments on this thread) have opinions about how “easy” it is to implement request retries and caching/service workers.

I have an opinion too. But my opinion and your opinion really are moot.

Because do you know whose opinion is probably backed by the most data and the most expertise? Google’s Gmail team.

And Google, with all its amazing developers, who are arguably at the forefront of javascript standards and general web app innovation, and who have literal billions of visits, they have made the decision to give you a link and tells you to use a basic, server-side rendered web app if you have a “slow connection.” And they do this while attempting to boot up all the PWA/SPA framing of the main app, just in case, I don’t know, all that stuff fails.

So I think I’m going to give Gmails opinion a lot of weight here


Gmail's slow connection message is great, but it's there because Gmail is a multi-megabyte app that will take a long time to download if you're on dial up or something. That's a bandwidth issue rather than latency or line quality problem. None of the points I made say anything about bandwidth.

I completely agree with the point you're making though; if a user is on a low bandwidth connection then sending as little data as possible is best, and that's likely to be plain HTML with very little rich content like images.

That said, Gmail's slow connection UI is horrible to actually use. Very few people choose it over normal Gmail. Most people want the big fancy app, so we as developers should work out the best way to deliver that.


Did you try using the site with the inspector open with Poor 2G throttling? I was still able to interact with the page within milliseconds. Just had to wait for the font to download before text would appear. Then after that, all of the assets besides the HTML was cached.

I think that's pretty damn good; to solve the 2 second latency, I think the developer is better off using a CDN or Netlify's ADN so that your site is delivered from a server closer to the user.


> If only you'd written an offline-first PWA and used background-loading and prefetching with some intelligence to retry failed requests in order to deliver content before I actually need it this would have worked so much better.

This is a unicorn. If it's the real world we're talking about, as far as I can tell client-heavy webapps that are actually engineered this well -- and don't frequently end up in a more inscrutable state than a pageload failure when network issues rear up -- are rare enough in practice that it feels weird to hold that up as the yardstick for criticism.

And if the point is that more applications should get there, well, that's more or less orthogonal to the point of the article, which (in spite of the headline) isn't so much that no one should use JS for anything ever (since the author details the JS he made a thoughtful choice to include), but that a notable range of UI behaviors that are frequently implemented using JS without a second thought don't necessarily have to be, and there are plausible benefits to the alternative. So this isn't exclusive with background loading / prefetching.


Agree that an offline-first PWA is the way to go. Not _no_ javascript, just _as little as possible_. However, I've also not seen such a good example before of how doable this is, so thanks to the author for the show-and-tell. The label/checkbox example is a new one on me, and covers pretty near 80% of my use of javascript. It's interesting how when you strip html of all the DOM api nonsense it starts to look like an exciting new framework. Forms are such a nice, declarative way to get user input.

It's also possible to cache server-rendered pages offline with a service worker. Admittedly not many people do this, but there's no reason why they couldn't, and it would probably be smaller for a lot of sites.

Prefetching is going to waste data in a lot of the world where you pay by the megabyte.

Everything is a tradeoff.


You prefetch what is required, and cache what is requested.

Assuming you aren't one of the sites that thinks it's appropriate to require `DOOM.WAD`, it can work out well.


> it drops every 10th request

Who has good heuristics for retry (or other techniques) to achieve reliable communications for a PWA?

We do retries, with a few different strategies, but we have a poor idea of exactly how effective (or not) our retries are. Also my code for this is ugly and it's a nasty area to test properly...


> If only you'd written an offline-first PWA and used background-loading and prefetching with some intelligence to retry failed requests in order to deliver content before I actually need it this would have worked so much better.

Then I would have waited too long to load the page the first time and give up.


The code you received the first time you load the app should be identical to the server-rendered version with a single additional script tag that loads a small JS file asynchronously. That script then progressively enhances the page to make it a PWA with features that take advantage what your browser supports.

Not enough developers build this way yet though because it's quite hard work. In my opinion the answer is to use what browsers are capable of; it should not be to ignore the browser and do as much as possible on the server.


These are handy tricks, even in JS at scale, and I'd recommend their usage if you can (big if, business requirements come first for most of us). That said, I don't really buy into the no JS/purism movement for load/execution speed. For bite-sized apps or simple pages, sure. However, it's completely possible and not that hard to develop full-blown web application suites using full JS for everything (structure, style, and function) and not have issues with load or speed. I'm not sure if there's a footgun here, but the issue falls squarely on the developers.

Seems like once again people just need to pick the right tool for the job. The problem is that people get stuck into one framework and it’s familiar to them so it gets forced into a project it doesn’t make sense for down the road.

"people just need to pick the right tool for the job" is utterly useless advice, just as "you should do the right thing" is an utterly useless answer to an ethics question, because it doesn't help you decide what the "right" tool/thing is.

There are lots of considerations in answering that usefully. Fit for the particular problem domain is one of them, yes. But so is familiarity. And ease of hiring. And performance, stability, maturity, state of tooling, community, training resources and a zillion others. How do you balance all those? Wait, let me guess, "correctly".

Sorry about the snark, this has just been a personal peeve of mine ever since the Slashdot days, when any word salad whatsoever would get upvoted Insightful provided it contained the magic phrase "right tool for the job".


I don’t deny any of those things. I think you’re reading way too much into my statement. I understand why people pick familiar tools and the cost of hiring and training people and getting up to speed on new stuff. It’s always a balance, and it’s why I don’t really like these posts that completely dismiss JavaScript and act like it has zero benefits.

I was on a team recently that only wanted to do Rails apps. They only wanted to make monolithic apps. Any mention of a more modular design would be met with derision. I don’t think this attitude is unique, though. And it’s really hard to overcome and see balance when the entire team clearly has no interest in changing or updating their skill set.


It’s a quip used to remind people to work backwards from the problem they’re trying to solve, not the other way around.

I think it’s an appropriate response to blanket advice on choice of tech stacks.


It wasn't posited as advice to a specific question, but rather a guiding principle, which is still valid and bears repeating given the frequency of the mistake.

Couldn't agree more. Anybody sitting down to start a _serious_ project should spend some time possibly researching and definitely planning, which would hopefully lead to the right decision here.

The whole thing is a solved problem. You can easily render React apps on the server and send HTML down the wire, then lazy load the rest of the JS. Author could have installed next.js and called it a day.

If you put your app logic in something like Redux it'll work on server-side rendering, client-side rendering, and can be included in react-native down the line.

In the time the author re-wrote his app, I could have gotten the same benefits with SSR and ported it to react native. But yeah, javascript bad REEEE


> Author could have installed next.js and called it a day.

Not a day, but probably a week of debugging. Each and every suggestion you made in your comment makes the deliverable tremendously more complex, is very expensive, will need ongoing maintenance, and is ultimately not needed.

Javascript apps are tremendously complex, why would do this if you don't have to?


Imagine you have a team of rails developers and you're asked to create a simple portal. Rails as a tool may be "overkill" but what does it matter?

If you already know Rails I'd say use that. If you only knew ruby then reaching for rails would be overkill. But if your business requirements need the features of Rails, learn rails instead of rolling your own framework..


I completely agree with you, which is why I think that telling people to "just install next.js" is a terrible advice. If they are JS devs, experienced in next, sure, go right ahead, but I don't think that's the case here.

I'd be fine to just use Rails for something like that since I'm quite familiar with Rails, but I would never recommend it to someone who doesn't know it.


> If they are JS devs, experienced in next, sure, go right ahead, but I don't think that's the case here.

The author is clearly experienced in UI development. The app was already written in React/Redux. So honestly, yeah, just install next.js and fix your routes.

This solution would be a complete non starter for any professional project in terms of accessibility - there's a few issues screen readers would run into with this. Not only that, but good luck getting other developers to sift through your spaghetti code.

But the main thing is, the authors goals are somewhat pointless. If you don't want a SPA then just use jQuery. The author ended up using plugins anyways so the whole story was aimed at people who don't know front-end but latch onto this idea of javascript is baaad. Don't be that guy.

So to recap. If you don't know javascript, and you don't want to learn the standard tooling - please don't roll your own framework and blog about it.

Edit: looks like someone already commented this on his blog. This is all you need to know: https://dev.to/isfotis/comment/9c7k


I am genuinely curious, what kind of Rails features can satisfy which business requirements?

I thought people use Rails mainly because they like it or are thrown into a team that already uses it.


The ecosystem is even today the main selling point to rails

> I could have gotten the same benefits with SSR and ported it to react native

Are you saying that rhetorically? In my experience, React is no silver bullet (e.g. different router and styling mechanisms for RN), trickiness dealing w/ timezones in SSR, etc.

And besides, the point here was largely about bundle size and fast time-to-interactive. Next.js optimizes a lot for developer experience, but you're definitely still going to be shipping a pretty sizeable JS bundle with slower characteristics than a hand-coded "closer-to-the-metal" thing.


> Are you saying that rhetorically?

No.

> And besides, the point here was largely about bundle size and fast time-to-interactive.

As long as the point wasn't to be productive I'll just mind my own business.


A lot of people here (including the author and myself) who have written multiple production applications using React and Redux will know that "just install next.js and call it a day" is a wild oversimplification. In fact, some of us were earlier adopters and enthusiasts of SPAs and flux architecture. You're seeing more and more write-ups on the problems with this approach because the early adopters are now long past the honeymoon and are entering long term maintenance.

> I built the first version of Slimvoice on Angular 1 with a Node.js backend and MongoDB in 2014 (those were all the rage back then). In 2015 I decided to completely revamp the UI and redesigned and rebuilt it in React.

Maybe you should make decisions based on requirements instead of hype. Oh wait:

> Don't follow the hype

But using less javascript is the hype today...

> Plain Old HTML and CSS

This section only shows some very basic UI elements (dropdown, expansion panel, ...). This isn't what libraries like react solve.

> Absolutely nothing is complex about my code

I wouldn't label CSS hacks with invisible checkboxes under "simple and self-explanatory code".

> I found myself wishing for more innovation in the HTML spec

I don't think adding even more bloat to even more web standards than a browser already has to support is the anwser.


> But using less javascript is the hype today...

I don't know, the hype is usually In React, Vue, etc.


> But using less javascript is the hype today...

Is it? This article on npm weekly (https://medium.com/npm-inc/npm-weekly-133-billions-of-packag...) says 4 billion packages were downloaded in a single week - representing multiple packages per week per human on earth. (Granted, this was Feb 2018, which is 2.8 millennia ago in JavaScript years.)

This site (on which you can't use the back button after choosing a graph) seems to show downloads still growing for popular packages. https://www.npmtrends.com/


> HTML innovation

not strictly HTML, but there's a lot of interesting goodies coming down the wire:

https://css-houdini.rocks

https://ishoudinireadyyet.com


kabes is to the point! It is fashionable to hate on modern front-end frameworks these days.

Imagine the OP grows their platform/company, hires a bunch of devs, what a nightmare that would be to keep avoiding JS and build on the product.

All so just because using JS is so mainstream, ugh.


This is totally true. We've recently started to discover this paradox ourselves: when styling and layout is all done via CSS, and JS + other assets are cached, HTML is just as light weight as JSON over the wire. As ashamed as I am to admit it, our newest innovation appears to be "multi-page apps"!

I remember there was some ridiculous article here where the author claimed to build world's fastest web app with PReact. It was a hierarchical list of HTML5 features with some tick-boxes. Out of curiosity I converted the giant JSON blob to <ul><li> list. HTML was about 15% smaller than JSON. You could also do most of the "logic" of the app via styling and normal HTML controls.

The benefit of JS comes in incremental updates. When you update that list with a new item, you can use optimistic update and small payloads in JS, while in HTML you have to load the whole page again, which is slower.

The main issue I have with this idea is that in practice I've almost never found the difference in payload to matter all that much, even on bad connections.

In some cases, even sending the entire HTML document and diffing on that using morphdom (because redrawing does bring noticeable cost rather quickly) was a viable strategy even compared to the most optimal json payload.

I'd very much like to see some examples that prove me wrong though, because while I've done some experiments, I might be underestimating how complex many web apps are. It's mostly that the apps I built in hindsight were often better off with a more old fashioned server-side, morphdom, turbolinks (or maybe intercooler?) type approach.


It's not the payload size that matters really, but the latency of requests which you have to wait between interactions, making the UX synchronous and slow.

Good examples are, well, almost any modern and popular app. Like Trello for example. Users spend lots of time on the same page making micro-interactions, creating cards, moving cards around, adding tags, etc. You want to make the in-app experience as flawless as possible in these types of apps, and the initial JS size doesn't matter so much especially when it's cached. There's also lots of shared state and you might be saving multiple things on the server at the same time or uploading multiple files in the background while editing other parts. You might want to store data offline and sync later to the server. Once you have decent complexity, JS app with framework such as React help a lot.


> It's not the payload size that matters really, but the latency of requests which you have to wait between interactions, making the UX synchronous and slow.

I'd use websockets if that was an issue. That said, Trello is a good example where I do agree a web app is a great solution.


Firstly, the application I was talking about[1] didn't have real updates.

Secondly, no one stops you from doing incremental updates with HTML except they way you design your data structures and UI.

In fact, HTML has something that JSON doesn't. Semantics. This means you can create a generic setup for incremental updates based, say, on element IDS.

---

[1] https://hackernoon.com/10-things-i-learned-making-the-fastes...


You have to load the whole page again. It may be slower.

>We've recently started to discover this paradox ourselves: when styling and layout is all done via CSS, and JS + other assets are cached, HTML is just as light weight as JSON over the wire.

In other words, when the web is architected as intended, it works fine, even with javascript.

Imagine that. It's like the problem isn't javascript per se, but unnecessary complexity.


lol this needs more visibility

Yes, the keys in JSON take up about as many bytes as the tags in HTML.

This write-up mostly highlights the loading speed and bandwidth benefits but not requiring javascript is far better than just that. In the age of spectre and with browsers exposing more and more bare metal functionality the idea of running arbitrary code on every random site I go to is absurd. There's dozens of us that simply don't run JS. Sites like these (and, say, the way chicago public media does fallback for no JS) show that there can still be pretty, functional sites without the modern equivalent of opening that .exe attached to a random email.

Thanks and keep up the good fight.


> There's dozens of us that simply don't run JS

Was this intentional? It gave me a bit of a chuckle.


I saw some actual statistics recently on a link from a blog with a lot of posts about accessibility (I forget which). It said that 1 in 98 users (1% of visitors) didn’t load JavaScript in a page, and 0.2% of visitors didn’t load the script because they had explicitly disabled JavaScript, as opposed to other reasons such as a poor network connection.

It was an acknowledgement that there aren't enough people like myself for web devs at for profit businesses or institutions to care about.

I'm not sure if you meant this or not, but there's text.npr.org. Honestly I'd prefer much of the web this way. I'd be OK with images too.

I like the slogan "JavaScript-free"! Finally something to rally around.

I don't mind projects which use a tiny bit of hand-coded, vanilla ES6. Would be nice if there were a slogan that included these.

Looks like it actually does use JavaScript for the "select2" case. This is exactly the case I'd be happy to special case.

edit: added paragraph


http://vanilla-js.com/

It's got a badge and everything.


The term I've usually seen is "JS sprinkles". Not sure where it comes from — maybe DHH in the context of mostly-server-side Rails apps?

JS sprinkles became the stimulus package [1]

[1] https://m.signalvnoise.com/stimulus-1-0-a-modest-javascript-...


Honestly, a lot of this comes down to ignorance on a lot of points. You can do a lot with CSS2.x+ selectors, and it's awesome. That said, JS/JSS and component systems aren't bad either. It depends on what you're creating and who your audience is.

Most of this stuff isn't new, it's about a decade+ old at this point. Backend developers often tend to turn up their noses on web front ends, so they don't bother to actually learn anything meaningful, and just sit complaining constantly.


I think this ignores one of the main benefits of JS based page rendering.

In the days where I worked on PHP apps, all rendering was done on the server, and that came at a great cost regarding server side processing and the complexities of peak load times, along with some pretty hairy test cases.

With everything rendered in js, you are mostly just transferring static assets, so the browsers are doing the heavy lifting for you. The only things that end up taking up server CPU cycles and system memory were API calls that are easy to test, debug, and optimize. Also, those API calls can be cached, and become static assets for high traffic apis such as ones accessed on the front end.

If you do it all on the backend, you are doing all the rendering work, and it is hard to split off and optimize processing time for things.

Finally, for testing, it is really easy to unit test an API, and for javascript frontend work, there doesn't seem to be the code regression type bugs that are so time consuming, but when you mix the data api stuff with the front end rendering, unit testing becomes a big mess.

Bloat needs to be thought about, especially for limiting bandwidth, but just for curiosity, I checked out my own website which was using React and a bunch of libraries, and it was only 500K. This is about half the size of the banner image on that article. Some libraries are much larger than React, but going JS free and losing the power React gives you doesn't seem like a good trade off.

Of course if you get some happys from being an ultra-purist, then I get that, and that is priceless. From a practical perspective though, this seems misguided.


How do you guys achieve this in practice?

I made my home page without javascript, and it is blazing fast. But as soon as I try to make something more complicated I bumped into practical problems.

- Components. I want to have the same navbar on all my pages, but I don't want an un-maintainable copy-pasted code on all my pages.

- Data. I need to display some data that is different for each user. How do I embed it in my webpage without ajax calls?

- Dev tools. I need debugging / bundler / source maps.

Some possible solutions could be:

- PHP. It has components through "require". You can embed the data easily. But, I do not know good dev tools: If I debug the javascript in the chrome dev tools, can I edit directly the php script? Can I minify/babel the output of the php code? And I cannot use the same php code on both front-end and back-end.

- Vue-SSR. Nice one-file components. Data can be provided within express. I can re-use the same code on the front-end. I have not tried yet, but it seems very interesting.

- EJS. It has require and data from express. It is very simple too use. But the tooling is lacking: no source map.


I try to go minimal javascript. There are two main ways you can limit javascript: static site generation or a rendering via a backend language.

Solutions

Use a templating engine with a backend language. My goto is jinja. For example you create a nav template and then include that template in your larger templates. You can then render different templates depending on the given route or file.

Alternatively use a static site generator. I use pelican. The static files are generated upon deployment from markdown for content, scss for css, templates for html, etc. There are plugins for using minifiers.

For user specific data, You can give the user a randomly generated session id cookie generated via a backend language. The backend language generates further pages based on information retrieved from the session id cookie. The session id would correspond to state in some database. Async data loading cannot happen without client side javascript.

- Dev tools: Write tests. the backend language would have developer tools such as a debugger. Generally you can run a dev server which allows to to drop a breakpoint upon failure. (backend frameworks can support this) Alternatively, you can change the rendered HTML via a debug flag (for local testing).

For PHP, The HTTP server serves the rendered files from the backend language's application server / module therefore you normally wouldn't be able to directly edit the backend code via a web browser.


Err, isn't everything you are worried about also served quite well by all server-side rendering frameworks since forever?

I legitimately cannot understand your issue.


You just probably know things that I don't know. That's why I am asking.

Which SSR framework do you prefer?


Just a stupid question. Why would you need a bundler for plain HTML?

I agree on everything else, but I kinda tripped on that and I'm not sure what you're actually looking for.


If you have a solution to avoid using a bundler altogether, that would be great. Personally, I would use it for:

- compression of html/css/images.

- css compatibility with old browsers.

- source map / auto-refresh during development.

- For any even slightly complicated app, you still need at least a bit of javascript. So, you need babel, minification, source maps, and so on...


"Why can't we have a standard search element that filters a list on the client side (similar to how ng-repeat | filter: worked on Angular 1)?"

It's pretty new, but: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/da...

"Wouldn't a standard HTML element for drag-and-drop sorting be awesome?"

There is a standard drag-and-drop API, but unfortunately (bafflingly) it's imperative/event-based, not declarative. Seems like it would be simple for them to add HTML hooks that use the same underlying code.


And a Datalist polyfill in the meantime https://github.com/mfranzke/datalist-polyfill (somewhat seems to defeat the nojs point though)

This is pretty much how I develop most of my web stuff. I do use JS, but it comes in afterwards, in discrete packages. It process specific HTML attributes to make the page do extra stuff, or accelerate certain operations, or stich pages together via AJAX. All scripts are stateless, because all state is stored in HTML.

The key is to represent your data and UI state via sane HTML. This article demonstrates this well with the modal popup example. Once you represent popup's state with a checkbox, you can manipulate that checkbox in any way you want and you can style it in any way you want and your styling will not have any dependencies on the methods of manipulation.


There is something like that the Elixir web community is trying to do with Liveview, Texas, Morphling and Whistle. Several competing libraries doing the same thing I believe, I've only seen Texas and Liveview in action.

The whole point, iirc, is to manipulate the DOM on server side and push those changes via a websocket. So the DOM manipulation is on server side and the code is server side language Elixir.

There was a demo for Texas and Liveview which show pretty good performance. I'm not sure if it is good enough performance but it looks promising.

Video for Texas: https://www.youtube.com/watch?v=NWgwUKfR8Xg

Video for LiveView: https://dockyard.com/blog/2018/09/12/liveview-project-at-eli...


I've played around with sending html strings via Phoenix channels and using morphdom to change only what needs to be changed. I'm quite happy with the results, even when sending an entire page for every significant change, and can't wait for LiveView to be released (estimated later this month, IIRC).

Nice work, I definitely appreciate the focus on simplicity/speed. I just signed up to check it out.

I noticed on the invoice page, on mobile, the number inputs (qty, price, etc) showed the full alpha keyboard on input. I think you can add a few attributes to optimize, without using JS also.

Great work, thanks for sharing.

This link has been helpful for me:

https://developers.google.com/web/fundamentals/design-and-ux...


Thank you! I had no idea that iOS required the pattern="\d" attribute. Those inputs require a decimal, so that pattern won't actually work (something like pattern="\d\.?\d*"). If I can get my hands on an iPhone to test that, I will deploy it shortly!

Awesome!

Definitely a few hacks involved. I’ve seen different combinations of using pattern, type=number, step=“0.01” etc, but you may need support for longer decimals in qty/price.

I’m always on the lookout for form best practices, but it’s definitely hard to stay up with all of the current trends.

There are a few mobile preview tools, not sure which is currently best, for testing on different virtual devices:

Google search: test site with iphone online


It is hard to argue against using JS. I tried that no-js approach as much as possible in the past, and hated it. Using React for front-end development and keeping bundle sizes small through good build processes is amazing. I genuinely enjoy building web front-ends now because of it, where as before I avoided it like the plague.

A nice way to progressively enhance something like this is to use Intercooler.js when you do want to update only part of the page. You're still just slinging HTML back to the browser but it lets you update only part of a page without using iframes or something, and since you're just adding data-attributes to links and forms, you don't write any javascript.

I would suggest using Vue progressively at that point. Refactoring our endpoints after using intercooler was not fun and using Vue/react without going full SPA let's you move on way easier

Slimvoice - A Webapp Without JavaScript is a series where I document how I rebuilt my app, Slimvoice, using as little JavaScript as possible.

Here's a recurring story in the programming field.

A new variation on technology is highly successful. The field starts using it enthusiastically, but doesn't keep track of the costs and cost/benefit. The new tech gets rather overused. Some people come out with optimizations. (Usually involving what amounts to caching.) Other insightful contrarian people take a minimalist approach. Rinse and repeat.

Once aware, one can spot this cycle happening. It is left as an exercise to the reader, how this can be used to profit.


While I'm not a full-on no-js developer, my move to the back-end and less javascript has been one of the biggest reasons why I've started enjoying my job again.

Unfortunately, at least judging by the many jobs I get offered, the market around me is still very much on the 'make everything a web app' train. I really hope the minimalist, or at least a less js-heavy approach actually becomes a new cycle, job-wise.


Funny, but the Smalltalk Seaside webapp framework was once criticized as old fashioned for this kind of server-centric, javascript minimal approach. And that wasn't that long ago.

While I understand the concern about bloated frontends, I do not understand the throw-the-baby-out-with-the-bathwater mentality of JavaScript-free front-ends.

Furthermore I feel like there's a misplaced sense of pastoralism or nostalgia about the-web-before-JavaScript. The fact is there was a very brief period where the World Wide Web was both widely accessible to the public and JavaScript free. I built my first website without JavaScript in 1995. By 1997 I was building incredibly interactive single page apps in IE4 with JavaScript and DHTML (as it was called at the time). By 1998 my full time job was writing cross-browser JavaScript. That's twenty years ago folks. jQuery didn't hit the scene until 2006. Why was jQuery created? Was it a revolutionary new tool that gave us the ability to create applications that heretofore had never been seen? Or, was it created to tame the horrendous mass of JavaScript that had already accumulated?

We can talk about bloat, but let's be honest about what the web browser is now. Chrome is an application container. The web hasn't been purely hypertext for a long time. Back when it was we complained about the bloat... of images


100 percent agree. Use as little JS as possible on front end. And then definitely use zero JS on backend.

Definitely...only use C on the backend, any other language is just a hack.

C is too high level and bloated. 20 kb for a hello world executable? That's just shameful.

Assembly language backends on the other hand absolutely scream.

And with a modern IDE they're a joy to develop.


I get the snark, but Java, Rust, Erlang are all better options than an interpreted language for backends IMO

Define better... Scripted languages can be run without the need for a compilation step, if you're scaling horizontally anyway, you can do nearly as well with node, and node can handle 100k+ connections per core with minimalish memory overhead. Functions are first class, functional approaches are easy and flexible, and when you're just passing bytes to another system or database, JS/Node works well.

As to interpreted languages, JS/V8 has probably seen more optimization than any other interpreted language. As to Java, you don't need a 400-500mb base image either. Rust takes much longer to develop against, as does erlang even if you're familiar with it. If you're parsing JSON into concrete objects, the overhead is often larger with compiled languages than interpreted, where JS just works. I can generally get stuff working in around 1/8 the time it takes for peers to use a compiled language to do the same.

Go is probably a better option than the three you suggested, even then more often than not, I would choose node, just because of the flexibility I get with npm and the larger community. If I, in turn need to eek more performance, or have a process that requires more compute per request, then I'll often reach for another language and/or even choose a Function as a Service wrapper.


Why not C++17 in combination with h2o? I don't know why the compilation step is an issue if compilation and linking takes less than a second which is less time than switching back to the browser. I can pass around lambdas with ease and my lines and functions have become much more succinct with the newer versions especially when dealing with web related stuff. In addition, the https://github.com/nlohmann/json lib make json just work.

No one seems to get that the C++ still works and in nearly all cases is faster, compiles very fast and is very quick to develop with now that everyone has shared their code and since functional algos have been added to the stl. This all happens with the memory safety people require since we have shared and unique pointers and Intel's thread building blocks. My fully featured application is 3.7 MB and takes 12-15 MB of ram to run and handles 100k+ requests per second from my laptop. Those stats aren't even that good with the exception of the rps.

If going fully native isn't your game then how about nginx with the plethora of 3rd party modules that are supplied by other developers? Maybe you just really like js? Maybe js isn't the best but you're going to use it anyway because you know it and other people have already written a lot of your code for you? Maybe you just feel like wasting money on more machines instead of one vps instance and a cache-everything cdn?

You do you I guess.


Who says I need multiple machines? I just said if you're going to design for horizontal scale, then it becomes less of an issue. Also, there's a lot to be said for most of the code available already written. My time is worth far more than paying a couple extra $ a month to run an app on a second server/vps.

I just said that JS isn't so bad, and that language snobbery is worse when it means you're far less productive.


We get that C++ still works, but we also get that unless you can have an iron grip on the team, third party libraries and CI/CD pipeline, someone will definitely write C in C++, or forget about all those 200+ UB cases, and then all is lost.

I'm a java engineer who writes lots of Elixir at home, and i _still_ don't agree with this sentiment.

Use the tool / language that makes the most sense for your problem.


nodejs and expressjs are pretty solid stable tools these days. And there is always typescript if you are into that.


I know... used to do CGI with C++ apps and Perl in the nid 90's. I was being snarky, but there are a lot of tools to do web requests in lower languages, and classic CGI did work well enough in a lot of ways, though the security concerns now are huge.

That seems a bit extreme. IMO that's a bit like saying "use zero Elixir/Erlang on the backend". I think a few people would take more contention with that line—and they're both languages running on VM's with a specific performance target.

I like this article, but the title is misleading.

"I did actually use some JavaScript on the new Slimvoice, but only when an interaction could not be replicated in any other way."

Overall, the article does point in a good direction.


Gotta shout out to the song linked in the article. Got me laughing good

https://www.youtube.com/watch?v=Yx6k6WR8GRs


One of the most inspiring web-related posts I've read in a long time...

This "no-JS" movement is cool and I love CSS hacks (in production?) but I also love the component mentality these JS-frameworks provide and not having to host frontend servers (other than for static files). Are there any good "pure" solutions for that?

To see more of this - sourcehut[0] uses most of these tricks and is open source so you can check out how they are used

[0] https://sourcehut.org/


Is it popular to hate on JS these days? Kudos to the author for creating the stuff but would you build the next Amazon.com avoiding JS? More often than not, I see Backend developers taking pride on not using JS rather than vice versa. Also, FB and GOOG aren't naive to spend enormous capital and manpower on React and Angular projects.

Probably will get downvoted but just because someone writes pure C does not make him/her a better developer than someone who just writes Javascript.


I'm still trying to grasp why these discussions so quickly spin into extremes. The author clearly states her intent in the first paragraph:

> With the new version I wanted to prove that it was possible to deliver an amazing user experience with a great design while drastically reducing the complexity of the code, maximizing reliability, and minimizing the cost to the end user.

She goes on to show us what she did, where it worked and where it didn't. The most important points I take away from her article are:

1. It's quite possible to build nice-feeling (YMMV), non-single-page web-apps without (a ton of) JavaScript

2. Critically evaluate if you need the complexity that an enormous JS framework brings

> You probably don't need a "Progressive Web App." Seriously evaluate if your app needs such complexity.

This has nothing to do with FAANG. Nobody disputes that there are use cases where it's a really good idea to use React+Redux+Jest+Enzyme+XYZ et al. But _maybe_ (and in my personal experience, in projects significantly smaller than Amazon.com, often) you simply do not need that amount of additional complexity and challenges.

It'd be so nice to just accept that the author provides an interesting data point (it can work without JS) in a community strongly biased towards starting projects by importing ~1000 node modules.


It is somewhat popular to hate on useless dung heaps of pointless Javascript, not because it's Javascript (writing complex code in a mediocre language with mediocre libraries is a separate concern), nor because backend developers have good reasons to do things in the backend, but because it's overcomplicated and so bloated that it causes performance problems, just like nested table layouts a few years ago.

> I wanted to prove that it was possible to deliver an amazing user experience with a great design while drastically reducing the complexity of the code, maximizing reliability, and minimizing the cost to the end user.

...

> The Website Obesity Problem is not getting any better for the web at large.

These are both important points. But remember that 50MB of CSS stylesheets is still very obese and very complex. Replacing bloated JS with bloated CSS is of arguable value.

Just saying...


I admit it, I hate single page apps. I see very few that actually work well. I don't hate JavaScript, it has its place, but you don't need to make an entire website an SPA. Stuff like the main Spotify, Slack, or Discord pages, and even things like Google Docs, and email front ends are fine for SPA. But you don't need to also embed all the FAQs and other crap into the SPA. You know what isn't an SPA? Hacker News. You know what else isn't? Google, GitHub, Amazon, and Stack Overflow. I've disabled the SPA version of Reddit. I've built SPAs and they are so much harder and take so much longer to develop and maintain than traditional web sites. I wish they'd just die. Sadly, everyone else at my work orgasms about SPAs, pushing every damn thing into it. We have stuff that works perfectly well and no one has ever complained about it? Screw it, let's spend $50k turning that feature into an SPA. I know many of you disagree with me and I'll get off my soap box now. </vent>

I had fun building our wedding website without any JS just to see how much I could push the boundaries of CSS and HTML. That was fun and a good learning experience. I'll now be able to build better apps _with JS_ knowing where it makes sense to push CSS/HTML and where it makes sense to use JS.

I recommend any front end engineer to go through that exercise, but it is not a good solution for real production systems.


it’s actually easy to do no-js websites when all you’ve got are forms, text and some images.

but there are a lot of use cases where js is essential.

it all comes down to what you’re building.


Author here.

Absolutely, and a ton of commenters (mostly on Reddit) seem to be missing that point. Use the right tool for the job. In the article I explicitly state that I couldn't have built the drag-and-drop invoice editor without JavaScript (although I wish that I could!).


You can even add huge "sign up for our newsletter!" text and button after every paragraph.

wow this is excellent, <details>/<summary> are good tricks

Except for the "works everywhere" suggestion...

https://caniuse.com/#feat=details

And here I thought Edge was a modern browser.


It's a basic DOM element — a block of content. Without native support, it's simply shown by default, instead of hidden by default, so nothing is broken, and even the default on non-supporting browsers can be changed with JS and CSS.

If anything, this is the works everywheriest of things that "work everywhere" in post-2010 web development. Some other stuff actually breaks accessibility by default.


Thx. Good to know. In that case, selective usage seems like good policy.

Given that Edge has less than 5% marketshare globally (depending on the source of the information), I would say that fretting over compatibility with it is not a priority. And given that MS is moving Edge to Chromium rendering engine, I assume this will solve the compat problem.

5% can still be a decent number of users, and tends to trend even higher in certain segments (state and local government, smaller "old economy" businesses)

And contrary to the article, it is possible to change their style!

So I decided to try and figure out this specific trick about toggling content and how well this would actually work in, say, a tab panel. I mean, it is a cute trick right? I made this: https://jsfiddle.net/sr8z1mob/6/

Yes, it is a cute trick. Yes, it CAN be made more accessible, and kinda sorta avoids the most obvious problems with like tabindexes and so on, although it did take a lot of work on my end for such an insignificant demonstrator, and I can't still set the active tab by hand in any way in here.

Which is a rather important cue about it's capabilities.

There's other things I cannot do:

- Use this as an actual component! I would have to set up an editor expansion to type all this stuff each time I wanted a tablist, and I cannot globally modify how all of them work. Making this into some kind of custom tag would be GREAT, but it could also probably mean going back to .htc files which is not so great.

- Track user interaction! It's important to us to know what the user is doing with our product so we can make it better. - Auto-select the first tab's content in all tablists without contorting my brain into a cramp - Load the tab contents lazily. Maybe you don't need the King James Bible (replace with any other long blob you like) loaded in there by default, just when you actually want to go look at the thing. - Skin the scrollbar easily (OSX for instance is a major PITA I'd like to have auto-solved for me) - Tell the server when the tab was scrolled to the bottom - Did I mention I cannot mark the current tab as open in any real meaningful way?

This is a fun experiment. But really, it all boils down to requirements and development times. Do you have the time and energy to spare to twist the browser into doing this kind of things? That's awesome!

I, more often than not, don't. That's sort of the reason why we use a development framework that puts us into a mindset we can work better with to cover more ellaborate scenarios (like being able to mark the currently open tab as exactly that without having to think about doing it).


The very-immature Phoenix LiveView kind-of fits this use case.

It looks AWESOME and I'm excited to watch it mature over time.

Basically, LiveView is an Elixir library that allows SPA-style web page interactivity with server-rendered pages.


Im not sure how elegant I think the CSS hack is compared to just making a simplistic script for it. Would a user really notice the parsing time for such a simple javascript application?

I object to considering the techniques in the article "hacks". They all employ minimal markup, without extra boxes or complicated classes, and the CSS side is very simple.

I give you that its not a verbose or complicated hack. but I still would say that a hidden checkbox acting as the middle man for modals etc is pretty hacky :). A hack doesn't need to be complicated, most times its not. But after all I can't imagine anyone thinking about this as a feature when they implemented checkbox inputs back in the days.

Author here.

I agree that it's a hack and I can't say that I like it. Blame the W3C and browser vendors for providing incomplete/barely functional standards like <dialog>.


This is pretty inspiring. I'm pretty interested to see their approach on the backend rendering. I've had some good experience in the good ol' days with server rendering.

I don't see how you go from "giant JS payloads that can render your whole site are bad" to "don't use Javascript to hide a DIV".

Maybe the CSS hack is faster than onclick="document.getElementById('zip-code-modal').style.display = 'none'" but it's quite likely not.


I totally agree that js is used way too much and dependencies are often included without ever considering the consequences.

But Javascript itself isn't bad. Just use it when it makes sense, and minimize it. Remove any dead code so phones won't have to spend cpu and data on it.


This is beautiful!

I gotta get better at CSS, I'm somewhat horrified by what I've done in JavaScript that it turns out I didn't need.

Does anyone know of a good book on intermediate/advanced CSS to help avoid excess JS usage/complexity?


MDN already has a bunch of courses on css:

https://developer.mozilla.org/en-US/docs/Web/CSS

If you are already familiar with basic CSS skipping to the middle is fine. A lot of modern CSS is just discovery of what you can do since none of it is really all that intuitive, but I generally end up googling "how can I do X effect in CSS" and seeing what the consensus is.

Just as some examples, you can do responsive bars that move all over the page, change their contents, have togglable collapse menus, have dropdown menus in those menus, etc all in plain CSS, but you can't have multiple columns of arbitrary sized elements in left to right top to bottom order.

Learning CSS is really just learning the contemporary limits of what you can do and then ruining your lovely responsive grids and flexboxes with absolute positioned px garbage when you have to support IE as penance for your crimes.



http://shop.oreilly.com/product/0636920012726.do

I haven't used it personally BUT it seems to cover most things I'd use these days, including "new" topics like grid, filters, etc. CSS is relatively simple so something of a reference with some examples would be great.


An approach I use is to try and build something in css first, if I can't find a way to make it work then I'll break out the JavaScript.

Css is surprisingly good in places, but it also drives me up the wall as soon as I let myself expect to be able to do more things in it. Yesterday it was gradient masks.


This is interesting and corresponds with the post https://builtwith.com/detailed/slimvoice.co

Maybe this is nonsense, but I wish I had a way to lazily load content (images) without JavaScript. The JavaScript solution is very minimal, but maybe an HTML/CSS option would also be simple.

Last year, I relaunched my website with just CSS – and I'm not missing anything. JS is used just for the error pages, featuring a game as optional content. :-)

Naive question - but how could you do any interactions (login, add/edit stuff that talks to a server) without using Javascript?

Hey, author here.

A lot of things are performed on the server, and then the server responds with a "flash" which is basically a little bar that says "Data saved." or "There was an error: ...".

There are a few places where I used a simple 5-liner to validate a field or something.

Unfortunately there was one place where I needed some heavier JS (for which I used Mithril.js), but it was absolutely required for when you're editing an invoice. You wouldn't want to edit line items and wait for a server response every time you make one change, so I simply determined that this was an area where I had no choice. Mithril simply modifies the DOM inside the <form> element, and then saving is a plain old POST request when you submit the form after you've made all of your changes.

The unfortunate reality is that I couldn't completely free myself from JavaScript, but got a lot closer.


Form posts to the server, just like the old days.

Of course, then you need a full page reload every time you edit something.


Not necessarily a full top-level page reload. You can POST to an iframe.

If you want to see the final status of the submission without JS, you still need at least part of the page to visibly reload.

Its generally good practice to start with forms and only start doing fetch requests for things you can demonstrate hamper user experience requiring refreshes.

Hyperlinks

It is all about trade offs. We had a good application developed as a SPA and worked well. However we had a monetization flow where we took users credit card details and bunch of information. We developed this flow as a separate stand alone HTML pages and micro optimized, reduced css, used vanilla js and put it on CDN.

That did bump up conversions by good percentage points. It is all about choosing the right hammer and nail for the job.


I'm amused by the Javascript mouse tracking used to rotate the phone image on the first page.

I thought the same thing. Of all the places that javascript could have been cut out, that had to be the most obvious.

I've been using intercooler.js (http://intercoolerjs.org/) on a project recently and absolutely love it... basically, it's allowed me to develop a web app with a modern feel without writing any JavaScript. Highly recommend it!

Why the downvotes?

Can't imagine anyone that's tried intercooler.js would actually downvote. It's really nice and, in my opinion, totally addresses the author's concerns.

This is really great but I was really surprised by that 230k number. Expected ~150k

Hey, author here. Just for reference, 180k of that is fonts. The rest is super tiny. Of course, once you've loaded it the first time, it's cached.

Have you tried minimizing that? Are you using WOFF2? Have you eliminated extra character sets/ranges? I know of a tool that can help:

https://www.fontsquirrel.com/tools/webfont-generator


Yes it's WOFF2, served over gzip. I do not think that I can eliminate extra character ranges because Slimvoice is used all over the world.

A website without JavaScript is like this comment.

well some needs to create a framework around this concept. Have the build process spit out only HTML and CSS that employ these exotic strategies.

It's entirely unsustainable to have a team build an app using these patterns.


Need to bump this. I hate JS.

weird flex, but okay

I think you missed the entire point of the article. Your account also has 2 comments, and both of them are "weird flex, but okay". You are in the wrong place if you expect those comments to be appreciated.

What JS does can be reduced to several things:

- storing states, and conditionally passing states around

- toggling things on or off

- element reuse

- dealing with events

- ajax

Unfortunately it's unlikely HTML & CSS would support all these.


The paradigm shift here is that most of these things would be done in the server using traditional techniques: ajax, events, state are all handled via form submissions. The only things in this list that are really "frontend-ish" are element reuse (which, for styling purposes, is accomplished via CSS methodologies) and toggling things on/off, which in the CSS-only corners of the web is accomplished using a radio box CSS trick.

Behavioral augmentation that these days is encapsulated via componentization (e.g. tabs, carousels) is also something that has been explored to death in traditional paradigms, e.g. unobtrusive js


We all knew these tricks and started from there back in the day. Don't you think they are way too hacky? and cause too many page refreshes? Have you ever maintained codes mixing server-side templating and JS scripts?

And there are so many edge cases popping up so that you have to use JS anyway. Then you may ask why don't I use JS for everything then?

JS is inevitable no matter how you and I hate it. "JS-Free" only makes sense for simple presentations.


Some things like the radio box trick are hacky, I agree, but many things are not. Personally, I like to strike a balance between old-school techniques and new technology (e.g. use CSS for hovers instead of instagram-style DOM manipulation via JS)

To me, this whole thing about JS-Free is a backlash against overdoing things in JS, and it's as good time as any to rethink today's status quo, especially in regards to how many babies we have thrown out w/ the bath water when adopting JS-first technologies.


Interactivity is a huge part -- moving things, adjusting parameters, live rendering, etc. Think D3, Crossfilter and such.

webrtc, webasm, webgl, and a million other things, right?



Applications are open for YC Summer 2019

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: