Skip to content

aarontgrogg/NoLoJS

Repository files navigation

NoLoJS

Reduce the JS Workload with no- or lo-JS options.

I have nothing against JS,
but it has better things to do
than manage your accordions and nav menus...

For years, JavaScript has been the web's workhorse. If HTML or CSS couldn't do what we wanted, we grabbed JavaScript to do it.

While that has helped push the user’s experience forward, the web is choking on JS. So as HTML and CSS continue to get stronger, we should transfer any JavaScript workload possible to them.

This is an organic collection of common JS patterns that can be replaced with just HTML, CSS, and no, or very low, JS. As HTML and CSS continue to mature, this collection should expand.

Tip

Most components have variations within the parent folder (for example, opening css-carousels reveals 8 variations within).
And all components have a corresponding CodePen in the top-level README that demonstrates a working example.

Please feel free to copy these and suggest others; Issues and PRs are welcome!

Demo

Page using several of these NoLoJS patterns:
https://aarontgrogg.com/nolojs/

Resources

A lot of people have been writing on this topic for quite some time. Here are just a few (note, some are a bit dated now, so buyer-beware):

And here are a couple of fantastic all-around "no or low JS" resources:

There are surely many more examples, so please contribute!

Note

I was well into this project when I finally stumbled across the massive You-Dont-Need-JavaScript repo... And while it does have lots of examples, I find the lack of descriptions and demos disappointing/discouraging. Also, as all the code examples are full page, it can be hard to discern what is needed for the feature, and what is just to make the rest of the page work or look good... Anyhow, going to continue pushing forward with this, as I think it is a useful endeavour.

Contribute

If you'd like to add your favorite no- or lo-JS pattern, please submit a PR, and please try to follow this established pattern as much as possible...

  • If creating a new top-level pattern, name it after the feature, not the HTML element or CSS property; in theory, this should make it easier for people to find.
    Example: The use of lazy-load instead of something like loading or preload. Ideally someone looking to lazy-load something might find that more easily.
  • Within the pattern, create a top-level README.md that includes any other names by which this might be called, a brief description, and links to any variations of that pattern.
    Each variation should have a brief description, list whether it is "No JS" or "Lo JS", link to Baseline or CanIUse for that feature, and ideally provide a working example via CodePen or similar. Example: Within the accordion pattern, the README.md states "aka: Expanding Content Panel", how it is implemented and why that is a benefit, then lists (and links to) five variations of that pattern, including links to a CodePen for each.
  • Finally, within each variation, include a simple index.html, styles.css and script.js, each as needed, with as little code as is required to make the pattern work (not an entire HTML document). Ideally code can be kept to a minimum, to help with clarity and to reduce confusion, but feel free to include comments if you think they will help the user better understand. Try to eliminate unnecessary fonts, colors, margins, padding, etc., unless it is crucial to making the pattern work.
    Example: The accordion > adjust-marker pattern contains an index.html and styles.css file, each with the minimal code needed to make the pattern work. The HTML file includes a comment that the heavy-lifting is handled in the CSS file, and the CSS file includes comments explaining each various "bit" to the pattern.

If you find an error, or would like to submit an alternate or improved method for some pattern, please create an Issue, providing as much supporting information as possible, and ideally a contact method, should there be questions.

Contact

If you'd like to just reach out to me for some reason, please feel free to do so via email (aarontgrogg@gmail.com) or any of the contact methods listed on my GitHub profile.

About

Reduce the JS Workload with NoLoJS

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published