AngryHacker
AngryHacker

Reputation: 61606

What are the mechanics of producing bundled js and css files with master pages?

I have a .NET Core project in which the master page _Layout.cshtml page references site wide style and js files:

<link rel="stylesheet" href="~/css/site.css" />
<script src="~/js/site.js" asp-append-version="true"></script>

The Index.cshtml page, which utilizes the above master page, references page specific style and js files:

<link type="text/css" rel="stylesheet" href="~/css/landing.css">    
<script src="~/js/landing.js" asp-append-version="true"></script>

And then Contact.cshtml and About.cshtml also have page specific css and js files.

What is the correct method to bundle the site wide files with page specific files? Should I avoid referencing anything the in the master page and simply reference the bundled file in each page's .cshtml?

Upvotes: 0

Views: 44

Answers (1)

Renan Vasconcelos
Renan Vasconcelos

Reputation: 176

You reference in your Master Page all scripts and Style Sheets you share across pages. For instance, you could reference only jquery.

You reference in your pages scripts and styles that are used specific on that pages.

It sounds simple like that.

Upvotes: 1

Related Questions