JS widget for swapping images

Hi, I was wondering how I can add a JS widget to a long , scrolling page such that if clicked on it, it swaps the images to an alternative. I found a widget like this that is similar: Floating Social Share Bar In Pure JavaScript - Sharerbox | CSS Script

But I am not sure how to incorporate that into a jekyll site, how can I get started?

Add external CSS and JS scripts to head in default.html layout

And then add script tag there to run the code on pages.