3 Replies Latest reply on Jun 16, 2018 12:55 AM by Ussnorway

    Running script after Muse loads jQuery

    sirqus

      Hi!

       

      I've got a site that uses a cookie banner provided by OneTrust.com. I've placed the code that calls the JavaScript for the banner in the header (as instructed by OneTrust). OneTrust also provides a version of jQuery. When opening the site none of the content is loaded and only the banner is shown (only the text, not its background), and only when reloading the page does the rest load. This error exists almost exclusively on mobile phones. When disabling the jQuery provided by OneTrust the banner does not show at all. I know that Muse provides a version of jQuery, how can I make the cookie banner use that version instead? It seems that jQuery is loaded last in Muse and the cookie banner is loaded before that, making it not pop up at all. If I could run the script after all the content (and Muse's scripts) have been loaded, maybe it would work?

       

      Thank you!

       

      /Sven

        • 1. Re: Running script after Muse loads jQuery
          Thiago Viana Level 1

          The important thing is have a jQuery version compatible with OnTrust. It does not matter where it comes from.

           

          When javascript libraries are imported, they become available for the entire page.

           

          Did you try to inspect the page content (Right button of the mouse> Inspect)?

           

          A good thing would be to share the site here, so we can look at it together.

          1 person found this helpful
          • 2. Re: Running script after Muse loads jQuery
            Nancy OShea Adobe Community Professional & MVP

            Try this one that does not rely on jQuery.  Paste this code into your document's <head> tag.

             

            <!--Cookie Conset CSS-->
            <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.css" />
            <!--Cookie Consent JS-->
            <script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.js"></script>
            <script>
            //Invoke Cookie Consent on page load
            window.addEventListener("load", function(){
            window.cookieconsent.initialise({
              "palette": {
                "popup": {
                  "background": "#000"
                },
                "button": {
                  "background": "#f1d600"
                }
              }
            })});
            </script>
            
            
            
            2 people found this helpful
            • 3. Re: Running script after Muse loads jQuery
              Ussnorway Adobe Community Professional

              yes the load | run order for code in Muse is [page head] then [page body] then [Master] head and [Master] body so for times when you need an order to things... like a popup timer you can split the code into different areas to have them run at different (but sequential) times

              Screenshot (964).png

              Screenshot (966).png

              Screenshot (965).png

              p.s, remember this bootstrap demo Nancy?