• i have the following problem:

    i have implemented a cookie banner on my website, but it loads last. it should load directly first, but i have no idea how to do that with wordpress, so i downloaded this plugin. despite inserting the script as async loading, it loads last.

    have I set something wrong?

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Optimizing Matters

    (@optimizingmatters)

    try to switch to defer instead of async maybe, deferred JS loads later then asynced JS? ??

    Thread Starter dvlzgrmz

    (@dvlzgrmz)

    it doesnt changes anything – i already tried it and also cleared the cash everytime, here is a screenshot of my settings, maybe ive done something wrong here?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    AsyncJS cannot delay more then what defer does. Additionally you seem to have WP Rocket lazyloading the JS, which makes it execute even later, so I doubt AsyncJS can help delaying more really ..

    Thread Starter dvlzgrmz

    (@dvlzgrmz)

    I also tried to deactivate WP Rocket, but that doesnt affect the loading time of the cookie banner – it is still loading at last – i already tried it – but nothing changes.

    so what do you think can solve my problem?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    Ah, I misunderstood, you want the cookiebanner to load asap, not later. Makes a lot more sense!

    You definitively don’t need AsyncJS for that (disable it or if you need ot keep it exclude the cookiebanner from being asynced) and you should configure WP Rocket to not lazyload the cookiebanner JS.

    Apart from that; I would ask the developers/ support of the cookie banner, they should know? ??

    Thread Starter dvlzgrmz

    (@dvlzgrmz)

    Thank you, but like i already said i also have deactivated WP Rocket and the issue is still there. I also lazyload the cookiebanner js in WP Rocket, but it still loads last – that is the point why i was trying this plugin here – because the other one doesnt worked.

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    but that’s the thing; you should not lazyload or async or defer the banner JS at all, because all of those make the cookiebanner load later, not sooner.

    Thread Starter dvlzgrmz

    (@dvlzgrmz)

    ok thank you, but how i get the banner to load before all other content?

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    I see the one of the two usercentrics JS-files still has the async flag, see if you can (configure it to) have that removed?

    
    <script id="usercentrics-cmp" async data-eu-mode="true" data-settings-id="VQ-ffiSXepQZ7X" src="https://app.eu.usercentrics.eu/browser-ui/latest/loader.js"></script>

    if all else fails get in touch with the cookie-banner developers, they should be able to help better than me ??

    Thread Starter dvlzgrmz

    (@dvlzgrmz)

    Thank you for your help, but it doesnt have to do with the cookie-banner developers, because they doesnt have any effect on when is the banner loading at MY page, you know? The problem is that anywhere in WordPress (or maybe in the theme) there is a rule that say “load xy first” but i dont know where i find it. I also be in touch with the theme developers, because like i said: The cookie-banner developers doesnt have any affect WHEN the banner is loaded on my page.

    But still thank you for your time and help.

    To ensure your cookie banner loads promptly and as the first script on your WordPress site, consider the following steps:

    1. Placement in Header/Footer:
      Ensure that you’ve placed the cookie banner script in the header section of your WordPress theme. This can typically be done in the theme files or through your theme customization options. Placing it in the header ensures it loads early in the page rendering process.
    2. Use a Dedicated Plugin:
      Instead of embedding the script manually, consider using a dedicated cookie banner plugin from the WordPress repository. These plugins are designed to handle cookie consent efficiently and often come with options to control script loading behavior.
    3. Plugin Settings:
      If you’re using a cookie banner plugin, check its settings to see if there’s an option to control the script loading order. Some plugins provide settings to prioritize their scripts.
    4. Check Theme Settings:
      Some themes have specific settings related to script loading. Explore your theme customization options or settings panel to check if there are any options related to script loading order.
    5. Caching Plugins:
      If you are using any caching plugins, clear the cache after making changes to ensure the updated script order takes effect.
    6. Theme Functions.php:
      If you’re comfortable with code, you can enqueue the script directly in your theme’s functions.php file using the wp_enqueue_script function. Ensure that you set the dependencies correctly to control loading order.
       function enqueue_cookie_banner_script() {
           wp_enqueue_script('your-cookie-banner-script', 'path/to/your/script.js', array(), '1.0', true);
       }
       add_action('wp_enqueue_scripts', 'enqueue_cookie_banner_script', 1);

    Here, the 1 in add_action ensures that this script is loaded with a priority of 1, making it one of the first scripts to load.

    Remember to test these changes on a staging site before applying them to your live site to avoid any disruptions. If the issue persists, consider reaching out to the support forums of the specific cookie banner plugin you’re using or seek assistance from your theme’s support channels.

    Below are the links to the finest learning platforms
    W3 School
    Iqra Technology
    JavaPoint

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘cookie banner loads at last script’ is closed to new replies.