I’d recommend using asset bundling as part of a pipes workflow.
Basically you want to keep your individual script files inside assests/js then slice these together and store in a variable. The you can create conditions based on what scripts you want to show on what pages. Check out this implementation here.