If you have build your homepage using blogdown, it’s actually quite simple to integrate Javascript snippets in it. While this is mentioned in the book “blogdown: Creating Websites with R Markdown”, it still took me a little bit to undertstand how it works.
As an example, let’s make different versions of a simple plot and let the user decide which one to display. First I make the plots and save them in a sub-directory: