You can make a partial signal on the layout page so that it includes a script, for example, using the IOC scope or HttpContext Bag. which is read on the layout page.
The only and main problem is that the script will only be in this package, as soon as it is partial, and then, most likely, your html head section is already closed in the layout. Thus, it is great for adding scripts at the bottom of the page, but it will not work for css.
It is best to create your own kind of components (or extend them) and specify an option to specify the necessary views. IOC these components at the top and visualize them where necessary.
The best solution
A better solution would be if half the pages needed this java-script to link it inside the main package. minifier is likely to be able to minimize more variables, and the user will need to request 1 less script (http request) for the loaded page, thereby creating less traffic, creating a faster page loading, creating a better user experience.
Joel harkes
source share