I mean I hate JS as much as the next person. Also, for my blog I wanted to use as minimal JS as possible. But when it comes to a sidebar I don't think adding a few lines like this is soo bad.
I'd be a little concerned with using this in production, because it would make your menu completely unusable for anyone without JavaScript enabled.
As with most things, the ideal is somewhere in the middle - use these techniques to get a baseline, then embrace progressive enhancement and round off the rough edges with JavaScript
I love no-JS type hacks and solutions as your post has suggested, but I would actually be more concerned about using solutions like your hidden menu in production than what the parent has suggested. Some of them, like the checkbox dark mode, are indeed hacks and cause issues with accessibility, and when I've tried a suitably complex burger menu without JS, I find it a buggy and annoying UX.
I think the true progressive enhancement route would be to render the menu either visibly on the page (maybe at the bottom?) or on a separate page entirely. Your burger menu icon is a link (either an anchor to bring the menu into view or to the dedicated menu page) and if JS is supported, you hijack the link using code similar to the parent comment and add a class to bring the menu element into view from there.
In doing so, your page can work just as HTML, not even CSS required, and if JS is supported then you have real state management to control the visibility of your menu (although accessibility concerns still potentially exist if you're not careful!).
It's unfortunate that you are getting downvoted for a legitimate response. Switching off JS saves power considerably and there are folks disabling JS all the time. They don't get tracked and so are mistakenly considered a super-minority by the JS devout here.
Many people have built a career around JS, and are unhappy when their holy cow is considered a future hamburger.
JS has its uses. The majority of UI elements should not involve JS though. Unfortunately, UI also provides low-hanging fruit for beginner-level JS developers to tangle with.
About 98% of people have javascript enabled, and most of the rest will unblock your site if they need to use it anyway.
The remnant who absolutely refuse to run javascript under any circumstance aren't worth worrying about unless you want to appeal to them, specifically, as a demographic.
> Sky accidentally block jQuery, Comcast insert ads into your script, and if you've never experienced this before, drive to an airport and use their wifi.
Sure, in the year of 2010 maybe... With https on almost every website this is hardly an issue now. We need more valid critism, not these outdated incidents to scare people
Yea i kind of agree also the way I have set up the page it is only an issue in mobile view. I guess the combination of no JS and mobile is even smaller.
On my previous project I used an anchor for the menu button, and the :target selector to make the menu visible. If JavaScript is loaded, it takes control. But without JS, it still works.