Hi jigar,
Follow there steps.
1. Add web.optimization from nuget.
2. Add BundleConfig.cs file and write below code.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Optimization;
/// <summary>
/// Summary description for BundleConfig
/// </summary>
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/sitejs")
//Add as many JS libraries you would like to the bundle.
.Include("~/Scripts/jquery-1.8.3.js")
.Include("~/Scripts/jquery-migrate-3.0.0.js"));
bundles.Add(new StyleBundle("~/bundles/sitecss")
//Add as many CSS files that you would like to the bundle.
.Include("~/css/jquery-ui.css"));
}
}
3. Register BundleConfig in Application_Start event.
<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Optimization" %>
<script RunAt="server">
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
BundleConfig.RegisterBundles(BundleTable.Bundles);
BundleTable.EnableOptimizations = true;
}
</script>
4. Add css and js like below just after the closing of </form> tag in master page.
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<%@ Import Namespace="System.Web.Optimization" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
<asp:PlaceHolder runat="server">
<%: Styles.Render("~/bundles/sitecss") %>
<%: Scripts.Render("~/bundles/sitejs") %>
</asp:PlaceHolder>
</body>
</html>