Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Ritesh 11 posts 91 karma points
    Oct 27, 2020 @ 14:00

    How to render two different JS Bundles using ClientDependency - RenderJsHere()

    Hi All,

    I want to render two different bundles of javascript files using RenderJsHere().

    I have placed it at two different places on my page but it's showing all files (1st group + 2nd group of files) at both places. Can anyone please guide me on how to render two different sets of files using RenderJsHere()?

    Below is some sample code.


        @inherits Umbraco.Web.Mvc.UmbracoViewPage
        @using ClientDependency.Core.Mvc
        <!DOCTYPE html>
                Html.RequiresJs("~/content/js/jquery-3.5.1.js", 1);        
            @Html.RenderJsHere() ===========  **1st group of files in header**
            Some HTML here
            Bottom of page
                Html.RequiresJs("~/content/js/bootstrap.js", 1);
                Html.RequiresJs("~/content/js/jquery.lazy.js", 2);
                Html.RequiresJs("~/content/js/slick.js", 3);
                Html.RequiresJs("~/content/js/app.js", 4);
                Html.RequiresJs("~/content/js/myjs.js", 5);
            @Html.RenderJsHere() **2nd group of files at last in page**
  • Richard Ockerby 25 posts 152 karma points MVP 2x c-trib
    Apr 12, 2022 @ 22:48
    Richard Ockerby

    This isn't something you can do; RenderJsHere and RenderCssHere will always spit out everything that has been registered.

    There is an open issue on the ClientDependency library on which this runs in Umbraco, but given it's age I don't think it's something a lot of people are looking for.

    Sorry it's taken a year and a half to hear "can't be done", but would love to hear if you came up with some form of workaround.

Please Sign in or register to post replies

Write your reply to: