I want to load JavaScript only on the home page of my site. I found this preprocess function but I don't know how to customize it for the home page:
function mytheme_preprocess_maintenance_page(&$variables) {
$variables['#attached']['library'][] = 'mytheme/cuddly-slider';
}
I was originally including the library I needed in every page of my site, but I only need it on the home page, so I need to figure this out.
Originally I had it in the .info.yml file like so:
libraries:
- 'themename/library'
Any help is appreciated.