Put JavaScript at bottom in NopCommerce

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hello

my issues with getting scripts to render at the bottom of the page.
YSlow getting error put all JavaScript File at the bottom
I put all JavaScript File at the bottom of the _root.head.cshtml Page
But my JavaScript Files are not worked and not supported in my NopCommerce Site

Please Suggestion me.....

Here is my Code for  _root.head.cshtml page

@using Nop.Core;
@using Nop.Core.Domain.Common;
@using Nop.Core.Domain.Seo;
@using Nop.Core.Infrastructure;
@using Nop.Services.Configuration;
@{
    var displayMiniProfiler = EngineContext.Current.Resolve<Nop.Core.Domain.StoreInformationSettings>().DisplayMiniProfilerInPublicStore;
    
    Html.AppendScriptParts("~/Scripts/public.ajaxcart.js");
    Html.AppendScriptParts("~/Scripts/public.common.js");
    Html.AppendScriptParts("~/Scripts/jquery-migrate-1.2.1.min.js");
    Html.AppendScriptParts("~/Scripts/jquery-ui-1.10.3.custom.min.js");
    Html.AppendScriptParts("~/Scripts/jquery.validate.unobtrusive.min.js");
    Html.AppendScriptParts("~/Scripts/jquery.validate.min.js");
    Html.AppendScriptParts("~/Scripts/jquery-1.10.2.min.js");

    //X-UA-Compatible tag
    var commonSettings = EngineContext.Current.Resolve<CommonSettings>();
    if (commonSettings.RenderXuaCompatible)
    {
        Html.AppendHeadCustomParts(string.Format("<meta http-equiv=\"X-UA-Compatible\" content=\"{0}\"/>", commonSettings.XuaCompatibleValue));
    }
    //custom tag(s)
    var seoSettings = EngineContext.Current.Resolve<SeoSettings>();
    if (!string.IsNullOrEmpty(seoSettings.CustomHeadTags))
    {
        Html.AppendHeadCustomParts(seoSettings.CustomHeadTags);
    }
    var browser = Request.Browser;
    if (browser.Browser == "IE" && browser.MajorVersion == 8)
    {
        Html.AppendHeadCustomParts("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"/>");
    }

    var isAndroid23Class = "notAndroid23";
    if (!string.IsNullOrWhiteSpace(Request.UserAgent) && Request.UserAgent.IndexOf("Android 2.", StringComparison.InvariantCultureIgnoreCase) > 0)
    {
        isAndroid23Class = "android23";
    }

    var currentStoreId = EngineContext.Current.Resolve<IStoreContext>().CurrentStore.Id;
    var useSecondaryFont = EngineContext.Current.Resolve<ISettingService>().GetSettingByKey("uptownthemesettings.usesecondaryfont", false, currentStoreId, true);
    var useProductThumbsWithPictures = EngineContext.Current.Resolve<ISettingService>().GetSettingByKey("uptownthemesettings.productthumbswithpictures", false, currentStoreId, true);
    var thumbsWithPicturesClass = useProductThumbsWithPictures ? "with-picture-thumbs" : string.Empty;
    var secondaryFontClass = useSecondaryFont ? "secondary-font" : string.Empty;

    string currentPageClass = Html.Partial("_CurrentPageClass").ToString().Trim();
}
<!DOCTYPE html>
<html @(this.ShouldUseRtlTheme() ? Html.Raw(" dir=\"rtl\"") : null) @Html.NopPageCssClasses()>
<head>
    <title>@Html.NopTitle()</title>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
    <meta name="description" content="@(Html.NopMetaDescription())" />
    <meta name="keywords" content="@(Html.NopMetaKeywords())" />
    <meta name="generator" content="nopCommerce" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0" />
    <link href='https://fonts.googleapis.com/css?family=Noto+Sans:400,700' rel='stylesheet' type='text/css'>
    @Html.NopHeadCustom()
    @*This is used so that themes can inject content into the header*@
    @Html.Partial("Head")
    @Html.Widget("head_html_tag")
    @Html.Widget("head_html_tag_after_css_files_uptown")
    @Html.NopCssFiles(this.Url, ResourceLocation.Head)    
    
    @Html.NopCanonicalUrls()
    @Html.Action("RssHeaderLink", "News")
    @Html.Action("RssHeaderLink", "Blog")
    @*Favicon - upload favicon.ico file to the root directory*@
    @Html.Action("Favicon", "Common")
    @if (displayMiniProfiler)
    {
        @StackExchange.Profiling.MiniProfiler.RenderIncludes()
    }
    <!--Powered by nopCommerce - http://www.nopCommerce.com-->
</head>
<body class="@currentPageClass @isAndroid23Class @thumbsWithPicturesClass @secondaryFontClass">
    <div class=" loader-overlay">
    <div class="loader"></div></div>
    @RenderBody()
    @Html.NopCssFiles(this.Url, ResourceLocation.Foot)
   @Html.NopScripts(this.Url, ResourceLocation.Head)
    @Html.NopScripts(this.Url, ResourceLocation.Foot)
    <div id="goToTop"></div>
</body>
</html>

above code in bold line is my all JavaScript files

Please Advice me ???
6 years ago
_root.head.cshtml is actually BEFORE the body.

You really need to paste your javascript somewhere into the bottom of the footer, which is here:
/Views/Common/Footer.cshtml
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.