• Is it possible to load jQuery first. I tried phast-no-defer to jQuery and WP Mega Menu JS and these added attributes just result in further javascript errors since WP Mega Menu can’t reference jQuery still.

    I am using WP Mega Menu on my site, and the problem is that the menu disappears after the WP Mega Menu JavaScript loads.

    The menu uses no-js CSS fallbacks and this problem occurs when the no-js class is removed during load.

    The developer gave me a CSS workaround, but this makes it so the menu isn’t accessible until the JavaScript is loaded. They say their code works as intended.

    If you are confused, please install WP Mega Menu to see for yourself.

    It’s very important that the user can interact with the menu ASAP before site is finished loading.

    Thanks,
    Kyle

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Albert Peschar

    (@kiboit)

    Hi @kw11,

    I’ve tested PhastPress with WP Mega Menu, without adding any phast-no-defer attributes, and it seems to work fine.

    Would you be able to share the URL of your site with me so that I can have a look for myself? If you don’t want to post it publicly, you can contact me using the details at the bottom of the plugin description.

    –Albert

    Thread Starter kw11

    (@kw11)

    After realizing that the mobile menu depends on JavaScript quite heavily, I was wondering what it would take to load jQuery before any other scripts.

    I successfully applied phast-no-defer attributes to the jQuery and WP Mega Menu scripts but I would get errors in the JavaScript console that jQuery is trying to be called before it’s been loaded/initialized.

    How can I load jQuery before other deferred scripts? And when doing this, does this typically take a big hit in page speed scores?

    I’ll consider sharing the URL with you after I hear back about these specific issues.

    Thank you,
    Kyle

    Plugin Author Albert Peschar

    (@kiboit)

    Hi @kw11,

    So one of the main things PhastPress does is delay script loading until the page has rendered. This has a large impact on the first contentful paint.

    If you start loading scripts and their dependencies earlier during the page load, that will slow down the first contentful paint.

    I don’t know exactly why you get errors despite applying the phast-no-defer attribute to the menu script and its dependencies. The phast-no-defer attribute makes the script execute in the normal order (the other in which they appear in the document) and before deferred scripts.

    The thing is, after the scripts are executed (if you don’t use phast-no-defer), the menu should just work. If the menu is broken, and it stays broken after the page has loaded, that might be a bug in PhastPress. (If I can see what the problem is and test a bit, I should be able to solve that.)

    If you really need these scripts to run earlier, the easiest thing to do is to turn off PhastPress script optimizations. That’ll make all scripts run before the page renders, as usually happens.

    –Albert

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Load jQuery first for WP Mega Menu’ is closed to new replies.