The use of JavaScript on the web can be very divisive, its abuses with trackers and privacy, and making pages excessively heavy are key reasons. Used correctly, however, it can enhance the experience and provide useful interactions.
I use a reasonably small amount of public-facing JavaScript to toggle comment sections, handle the highlighting of fragmentions and backlinks, etc. but nothing invasive. The code is the only way to achieve certain outcomes. I am aware that for some the distrust of JavaScript means they disable it – how they manage to operate when it is so pervasive I'll never know.
Still, with this in mind, I decided to add a little banner by way of a <noscript>
tag should this be the case.
The banner is dismissable purely using CSS by means of a hidden checkbox and a :not(:checked)
condition – click the X and the div disappears.
Without JavaScript I can't set a cookie to remember this without reloading the page and using $_GET
to set a PHP session variable but I think that's overkill.
@colinwalker Progressive enhancement is how the web should work. That those designing and building websites seem to have gotten that backwards is perhaps the biggest retrograde step in the development of the web, after the enclosure of most content by social media and apps.
I'm guilty here to a degree with comments but at least all the core content can be viewed okay. I think the problem is that technologies like JavaScript are so ubiquitous that we forget and opt for functionality over form.