What's the proper way to create a class toggle function for a slide in menu in Next.js?
I've created a menu, which has togglable slide-in functionality. There's a button which toggles a class "toggled" and then the menu slides in from the side. I'm not sure if such an approach in itself is wrong when using React/Next.js, in which case I'd appreciate alternatives.
So normally I would inline my toggle-script somewhere in the footer, to get optimal speed. It's a very small script, so it doesn't need to be included in a separate file. I just have no idea where to put this script when using Next.js.
I've read that you can use next/head and put the code in a separate file and include the file normally there, but that doesn't sound very optimal to me. This creates a separate request and makes the whole thing slower than it needs to be. And, if it needs to be done this way, how would you preload/push it if you wanted to do that?