I find that sticky sidebars are awkward to implement. There are plenty of examples out there, but most of them either use huge libraries to function or do not work well when implemented with non-fixed header and footers, or don’t handle bottoming out on the footer well.

Since I couldn’t find any suitable code examples, I created my own recently with raw vanilla JavaScript. I would love feedback on the code I’m using for this. If you have any constructive feedback, please post it below. I’m fairly new to writing JavaScript from scratch like this, so it would be nice to get some tips on how I can improve 🙂

The code | The demo