DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

Override loading location for JavaScriptLibraryInclude

 5 Replies
 1 Subscribed to this topic
 11 Subscribed to this forum
Sort:
Author
Messages
New Around Here
Posts: 7
New Around Here

    In my skin, I am using JavaScriptLibraryInclude to load popper.js and bootstrap.  It seems the modules load at the bottom of the HTML.  However, this causes issues with some modules.  I found through experimentation that if I load popper and bootstrap above the modules, everything works fine.  Is there a way to force JavaScriptLibraryInclude to specify the location in the page where the libraries will load so I can force them to load at the top of the page?  Or do I just need to go back to static js references?

    Veteran Member
    Posts: 1128
    Veteran Member

      Yes you can set the order.

      From the documentation HTH:

      DotNetNuke.Web.Client

      If you'd like to register a resource file in code, you can do so using the ClientResourceManager found in DotNetNuke.Web.Client. First add a reference to the assembly, and then make use of any of the API methods listed below. For more information about priority and providers, please see their respective sections below.

      There are a few different overloads for registering a stylesheet, the most common is listed first:
       

      RegisterStyleSheet(Page page, string filePath) //default provider and default priority
      
      RegisterStyleSheet(Page page, string filePath, int priority) // default provider
      
      RegisterStyleSheet(Page page, string filePath, FileOrder.Css priority) // default provider, uses FileOrder enumeration (primarily for internal framework use)
      
      RegisterStyleSheet(Page page, string filePath, int priority, string provider)
      
      


      There are also a few overloads for registering a JavaScript file, again, the most common are listed first.
       

      RegisterScript(Page page, string filePath) // default priority and provider
      
      RegisterScript(Page page, string filePath, int priority) // default provider
      
      RegisterScript(Page page, string filePath, FileOrder.Js priority) // default provider, uses fileorder enumeration
      
      RegisterScript(Page page, string filePath, FileOrder.Js priority, string provider) // no defaults
      
      RegisterScript(Page page, string filePath, int priority, string provider) // no defaults
      
      

       

      Relative Order

      There is an enumeration that defines the file load order (priority) of each of the internal files that the DNN framework is responsible for loading. They have been spaced out a bit so that an extension developer can sneak their files in wherever they like.

      Note: the FileOrder enumeration is not intended to be used outside of the core application. For instance, if you want to register something after jQuery but before jQuery UI - you would use a value of 6,7,8 or 9 when registering the script. Or you could use your own enumeration (e.g. MyFileOrder.AfterjQueryBeforejQueryUI) to give a good name to the number.

      JavaScript priorities:

      Default: 100
      
      jQuery: 5
      
      jQuery UI: 10
      
      DnnXxml: 15
      
      DnnXmlJsParser: 20
      
      DnnXmlHttp: 25
      
      DnnXmlHttpJsXmlHttpRequest: 30
      
      DnnDomPositioning: 35
      
      DnnControls: 40
      
      DnnControlsLabelEdit: 45
      
      


      CSS priorities:

      DefaultCss: 5
      
      ModuleCss: 10
      
      SkinCss: 15
      
      SpecificSkinCss: 20
      
      ContainerCss: 25
      
      SpecificContainerCss: 30
      
      PortalCss: 35
      
      New Around Here
      Posts: 7
      New Around Here
        Thank you, but I'm not sure how this applies to my case. This is a skin file, not a module. I'm modifying an existing skin. I'm using

        <%@ Register TagPrefix="dnn" TagName="JavaScriptLibraryInclude" Src="~/admin/Skins/JavaScriptLibraryInclude.ascx" %>

        <dnn:JavaScriptLibraryInclude runat="server" Name="popper.js" />
        <dnn:JavaScriptLibraryInclude runat="server" Name="bootstrap" />

        And it always loads at the bottom.
        Veteran Member
        Posts: 1128
        Veteran Member

          It also applies to skins.

              < dnn:DnnJsInclude runat="server" FilePath="/vendors/popper/umd/popper.min.js" PathNameAlias="SkinPath" Priority="10" />
              < dnn:DnnJsInclude runat="server" FilePath="/vendors/custom-bootstrap/js/bootstrap.min.js" PathNameAlias="SkinPath" Priority="11" />
            
          You can find more info on the priority and how it works here: https://www.dnnsoftware.c...ource-management-api

           

          Veteran Member
          Posts: 1128
          Veteran Member

            Ok, you are loading the installed libraries I'm not sure if they support an order too TBH

            New Around Here
            Posts: 7
            New Around Here

              Yes, that is the case.  Sorry if I wasn't clear.  I might have to move to statically loaded instead of that if I can't change that.  :-/

              These Forums are dedicated to the discussion of DNN Platform.

              For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

              1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
              2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
              3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
              4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
              5. No Flaming or Trolling.
              6. No Profanity, Racism, or Prejudice.
              7. Site Moderators have the final word on approving / removing a thread or post or comment.
              8. English language posting only, please.

              Would you like to help us?

              Awesome! Simply post in the forums using the link below and we'll get you started.

              Get Involved