Highlighted

Running script after Muse loads jQuery

Community Beginner ,
Jun 15, 2018

Copy link to clipboard

Copied

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

Most Valuable Participant
Correct answer by Ussnorway | Most Valuable Participant

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?

Views

336

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Running script after Muse loads jQuery

Community Beginner ,
Jun 15, 2018

Copy link to clipboard

Copied

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

Most Valuable Participant
Correct answer by Ussnorway | Most Valuable Participant

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?

Views

337

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 15, 2018 0
Community Beginner ,
Jun 15, 2018

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 15, 2018 1
Adobe Community Professional ,
Jun 15, 2018

Copy link to clipboard

Copied

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>

Nancy O'Shea, ACP
Alt-Web.com

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 15, 2018 1
Most Valuable Participant ,
Jun 16, 2018

Copy link to clipboard

Copied

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 16, 2018 1