How do I add individual css/js files per page through the minification api?
If you just want to add your own, unbundled scripts and use jquery-calls in a MVC 4 application that uses minification and bundling to include the standard libraries, here's an easy way of doing it:
By default the _Layout.chtml includes jquery and then calls
@RenderSection("scripts", required: false)
To add your own scripts that uses jquery to the page, you can add the content for the section like this (in your view):
@section scripts {
// At this point jquery is available. Include your own scripts here
}
Not to sound too much like a sales man, but you could also look at RequestReduce. You don't really need to create or declare bundles instead whatever js and css you already have on your page is automatically bundled and minified. One advantage here is if different pages have different combinations of js and css, each unique combination is made into a "bundle" by RequestReduce but you dont have to manage it. Everything is cached so there is no need to worry about runtime perf costs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With