Soooo, right here we basically have a sticky sidebar using minimum code.
All we do is add an empty div with id at homepage, right above the sidebar so we can get the upper limits without counting any paddings and margins the sidebar's css might already have.
JS file is self explenatory,
CSS must be altered to fit your website's need. In my scenario I cound not change the sidebar's position attribute, so i had to tweak it's position manually. In most scenarios transform: translate(); rule is not needed.
Credit is appreciated, hit me up for custom work on your projects!