• Resolved shqipe420

    (@shqipe420)


    Hi,

    I recently stopped using embedding jQuery on my local page. While testing with Lighthouse there occured an issue with „Best Practices“ and it claimed that a script from Astra uses jQuery and as it is not loaded jQuery is not defined.

    i just wanted to know if this is a common issue for users who do not use jQuery and if so whether it can be fixed.

    Thanks in advance!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter shqipe420

    (@shqipe420)

    In case this helps the console gives me this error

    “Uncaught ReferenceError: jQuery is not defined
    at frontend.min.js?ver=4.11.6:1:24929″

    which is basically the following code at the end of the script:

    jQuery(document).on("click", ".main-header-bar-navigation a", function() {
    jQuery("body").hasClass("ast-main-header-nav-open") && (jQuery(".main-header-menu-toggle.toggled").removeClass("toggled"),
    jQuery(".main-header-bar-navigation.toggle-on").removeClass("toggle-on").css("display", ""),
    jQuery("body").removeClass("ast-main-header-nav-open"))
    });

    Hi @shqipe420,

    Yes, you’re right—there’s currently a small piece of jQuery code used in Astra. This was added intentionally due to a specific limitation we encountered at the time. We noticed that plain JavaScript wasn’t handling a certain menu toggle sync reliably because of missing event delegation in some edge cases, so we used jQuery as an exception to ensure consistent behavior.

    We’ve documented this in the code itself with a comment for transparency—here’s a quick screenshot showing that: https://bsf.d.pr/i/otJv25

    That said, you’re not alone in moving away from jQuery, and we completely understand the push for cleaner, dependency-free setups. We’re planning to revisit this implementation in an upcoming release and refine it using pure JavaScript, provided we can preserve the same level of reliability.

    If this is something that’s affecting your workflow right now, feel free to share more about your setup and we’ll do our best to offer a workaround or further guidance.

    Best regards,
    Aradhy 😊

    Thread Starter shqipe420

    (@shqipe420)

    Hi @bsfaradhy

    Thanks for the heads up!

    Alright then in case you are already aware of this issue and are working on this then it is fine. As I said it is only a matter of Lighthouse results issue and therefore not crucial, but nice if it would be fixed in the future.

    If you think it’s gonna take some time to be fixed I would appreciate it if you have any idea how to use custom php/ JS Code to prevent this from causing the console error log.

    Best Regards

    Hi @shqipe420,

    We do have a dev version for this to give it an immediate fix. In order to test it, please reach out to us via our Support Portal. You can cross-link the thread so that we get an idea about it.

    Kind regards,
    Aradhy 😊

    Thread Starter shqipe420

    (@shqipe420)

    Hey @bsfaradhy

    Thanks for the info. I thought you may have a code snippet or something, but if not I can also just wait for the new update.

    Until that I will just leave this thread open in case I have some additional questions.

    Thank you very much again!

    Thread Starter shqipe420

    (@shqipe420)

    As a matter of fact with the new update this issue does not occur anymore.

    Again thanks for your help @bsfaradhy

    Hi @shqipe420,

    That’s great to hear—thanks for confirming! Really glad the update resolved it for you. If you run into anything else or have questions, don’t hesitate to open a new thread. Always happy to help! 😊

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘jQuery not defined’ is closed to new replies.