- Issue created by @iancawthorne
- 🇨🇦Canada joseph.olstad
Did you restart your varnish? Try testing with an incognito browser also.
Do a forced reload, you may have to reload your apcu service (opcode cache).
ctrl shift R
- 🇨🇦Canada joseph.olstad
a trick to break cache, on your url add ?t=random_number
- 🇬🇧United Kingdom iancawthorne
This was on a local setup with no caching enabled (no Drupal, Varnish or Redis)
- 🇨🇦Canada joseph.olstad
as a workaround you can downgrade jquery by theme selection in the configuration options. This should effectively downgrade it everywhere that your front-end theme is used. Rebuild drupal cache after adjusting the settings.
- 🇬🇧United Kingdom iancawthorne
Just to also clarify that this issue is when viewing the same page with the same theme.
ie viewing :node/1
Logged in: jquery file from this module loads last
Logged out: jquery file from drupal core loads lastThe solution I've implemented is to not have a dependency of jquery in the theme's libraries yaml. This results in the jquery file being loaded in from this module, rather than it being loaded twice.
- 🇬🇧United Kingdom iancawthorne
Yes, the theme had:
dependencies: - core/jquery
removing this results in jquery only being loaded once when jquery_downgrade is enabled.
- Merge request !1Issue #3516469 by iancawthorne, joseph.olstad: Module only works when logged in → (Open) created by joseph.olstad
- 🇨🇦Canada joseph.olstad
@iancawthorn, you might want to try out this patch, maybe play with the weight setting, I adjusted it to -99, maybe it needs to go to -999 or maybe it needs to be set to 999 instead of a minus number.
Alternatively, I created a jquery_downgrade_force module , however be warned, this affects the admin side as well, might not be good to use.
- 🇨🇦Canada joseph.olstad
Here's the patch file https://git.drupalcode.org/project/jquery_downgrade/-/merge_requests/1.p...
- 🇬🇧United Kingdom iancawthorne
@joseph.olstad I gave this a look and setting the weight to -99 or -999 didn't make any difference, however setting the weight to -1 does make the jquery_downgrade jquery request load after the core jquery as preferred.
That said, I think it's still not a good move to be loading the jquery library twice. Stopping the core jquery library from loading would be more desirable.
- 🇨🇦Canada joseph.olstad
@iancawthorne , did you try the merge request patch? it includes a new module called jquery_downgrade_force. apply the patch, rebuild cache, install the new module jquery_downgrade_force
- 🇨🇦Canada joseph.olstad
Hmm, I pushed up a change, might help jquery_downgrade, have a look at the patch: https://git.drupalcode.org/project/jquery_downgrade/-/merge_requests/1.p...
- 🇬🇧United Kingdom iancawthorne
I didn't try the jquery_downgrade_force module as you mentioned it affected the admin side too.
I'll try the new patch, but in the meantime, I just updated another Drupal site to Drupal 11 and noticed this was using the jquery_once module. This module also downgrades to 3.x jquery library, but removes the core library version being loaded in too. It may be of use for referencing logic.
- 🇨🇦Canada joseph.olstad
hmm, jquery_once isn't the same idea, what it does is add jquery once which was removed from core. Core now has an es6 once instead
whereas jquery_downgrade has to replace it. I prefer being able to control WHERE it gets replaced, that's why jquery_downgrade is designed the way it is, with that said, your feedback has been very important here. We probably didn't notice this during testing and implementing this.
- 🇬🇧United Kingdom iancawthorne
I've given the patch at #19 a try and can confirm does as per my note on #17 it moves the jquery_downgrade module library to appear after the core jquery library file. Both are present rather than just the one.
Re the way jquery_once. It adds in jquery once, but it also changes the jquery library version, so I think the replacement logic can be used in jquery_downgrade. I think it's rewriting where the "core/jquery" looks in its .module file in jquery_once_library_info_alter().
- 🇨🇦Canada joseph.olstad
ok thanks for that, I'll have a look in jquery_once and check what's happening.