Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
While anonymous and navbar dev is activated modernizr is not loaded.
Everything works fine when I'm authenticated.
With Navbar.
<style media="print">@import url("/sites/all/themes/mysite/assets/css/print.css?myzh03");</style>
<script>Modernizr.load([{
test: Modernizr.input.placeholder,
nope: /sites/all/themes/mysite/assets/lib/jquery.placeholder2.0.7.js',
}]);</script>
<script src="/sites/all/modules/contrib/jquery_update/replace/jquery/1.7/jquery.min.js?v=1.7.1"></script>
Without Navbar.
<style media="print">@import url("/sites/all/themes/mysite/assets/css/print.css?myzh1t");</style>
<script src="/sites/all/libraries/modernizr/modernizr.js?myzh1t"></script>
<script>Modernizr.load([{
test: Modernizr.input.placeholder,
nope: '/sites/all/themes/mysite/assets/lib/jquery.placeholder2.0.7.js',
}]);</script>
<script src="/sites/all/modules/contrib/jquery_update/replace/jquery/1.7/jquery.min.js?v=1.7.1"></script>
Comment | File | Size | Author |
---|---|---|---|
#58 | Issue-2167993-by-hass-Increase-module-weight-to-over.patch | 1.07 KB | hass |
Comments
Comment #1
Fidelix CreditAttribution: Fidelix commentedComment #2
Fidelix CreditAttribution: Fidelix commentedWell this pretty much breaks sites that depend on Modernizr for things other than navbar, so I'm bumping this to major.
Comment #3
Wim LeersWhich other module depends on Modernizr and how does it load Modernizr?
Comment #4
Wim LeersComment #5
Fidelix CreditAttribution: Fidelix commentedMy Aurora subtheme implements:
modernizr[Modernizr.input.placeholder][nope][] = 'assets/lib/jquery.placeholder2.0.7.js'
This fails to load and the browser console throws some errors due to modernizr not being loaded.
But I will close this since I can't reproduce this behavior on a fresh install.
By the way, not even with hook_modernizr_load (module) or hook_modernizr_load_alter (theme) the modernizr JS file is loaded.
Comment #6
Fidelix CreditAttribution: Fidelix commentedIf I remove $libraries['modernizr'] from navbar_libraries_info(), things start working.
I guess there is some sort of conflict with the modernizr module.
The only problem left is that I have these notices:
Comment #7
amaria CreditAttribution: amaria commentedI realize this is closed, but I was having this issue as well. The only way I could find to fix it is to use drupal_add_js() to add modernizr if it's not there, in a hook_js_alter() function.
Comment #8
jonathan_hunt CreditAttribution: jonathan_hunt commentedI ran into the same issue also. Here's my workaround, similar to #7:
Comment #9
Fidelix CreditAttribution: Fidelix commentedJonathan, then I guess this is indeed an issue that needs to be reproduced.
Are you able to reproduce this in a fresh installation?
Comment #10
jaydee1818 CreditAttribution: jaydee1818 commentedI am also experiencing this issue. I am using this module:
https://www.drupal.org/project/modernizr
After installing Mobile Friendly Navigation Toolbar, Modernizr is not loading for anonymous users and causes my site to break on IE8 and below.
Comment #11
mducharme CreditAttribution: mducharme commentedMarked #2316323: Integrate navbar with modernizr drupal module as duplicate of this issue.
I think this edit puts us on the correct path.
Comment #12
mducharme CreditAttribution: mducharme commentedSo it turns out we were already halfway there. As described in the modernizer documentation, contrib modules simply need to define their required tests in
hook_modernizr_info
- which navbar already does. This patch removes the code that adds the modernizr library itself. I've also left in the library weight definitions that ensure that modernizr loads before backbone and underscore. I've tested with the Aurora theme and everything works as expected.The documentation will need updating to point people to the modernizr module and to make sure that everyone understands that they must download a new production build by clicking button on the modernizr settings page in order to include the navbar tests.
Comment #13
tancThank you, the patch in #12 brings sanity to navbar's handling of the modernizr library. Tested and works as expected, navbar uses the modernizr module loading of the library rather than its own methods. Tested with Omega 4.x based themes.
Comment #14
mducharme CreditAttribution: mducharme commentedThanks for testing. This is a pretty major change that will definitely break for users who upgrade without following the instructions. Should a 2.x branch be started to integrate this change? How are backward-incompatible changes like this normally handled?
A 2.x branch could also move to using the backbone module and making both the backbone and modernizr projects dependencies so that navbar doesn't need any custom library installation instructions. I haven't reviewed that particular backbone implementation but it seems to have a similar library installation process to navbar.
Comment #15
Fidelix CreditAttribution: Fidelix commentedNo, the backbone module is not necessary in any way. It not only provides backbone but many more features not necessary for this module. And when you install it, you have to do the same steps that you need to do in navbar.
So I don't think it would be a good integration.
Comment #16
mducharme CreditAttribution: mducharme commentedAgreed @Fidelix. It would be nice to see a new "library-only module" for backbone though. A backport of https://www.drupal.org/node/1149866 might be an option. We can open a new issue if people are interested enough...
Comment #17
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedI am getting modernizr is not installed error on my status logs.
If the modernizer module is enabled, shouldn't navbar check via the modernizr module if it is enabled and use modernizr module library functions to check if the file is present in the library folder?
Comment #18
Fidelix CreditAttribution: Fidelix commented@SocialNicheGuru, have you applied the patch in the dev version?
Which patch?
Comment #19
holist CreditAttribution: holist commentedApplied patch from #12 on 7.x-1.4 successfully, everything peachy.
Comment #20
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedUpgraded to modernizr sept 22 dev, upated navbar and it seems to work now.
Comment #21
hass CreditAttribution: hass commentedi do not like installing full modernizer module only for navbar. The lib is very large where the required code here is very small. I suspect this code removal break every site without the moderizer module.
Comment #22
mducharme CreditAttribution: mducharme commentedThis issue exists because navbar conflicts with other modules that use the modernizr library. The best practice is to use a stand-alone library for third-party tools that all contrib modules can use. The module is required because we don't want to include every feature of modernizr but only the ones that modules need to reduce code.
navbar's modernizr.js = 3.6K
stand-alone library modernizr.js = 7.7K
combined mordernizr.js after applying this patch = 7.4k
I addressed the breaking of every site in comment #14.
Comment #23
mducharme CreditAttribution: mducharme commentedComment #24
mducharme CreditAttribution: mducharme commentedComment #25
hass CreditAttribution: hass commentedSorry, but You remove all lib checks. This module does not require modernizr. This patch is against 1.x and not 2.x. It doesn't matter if this solves issues for a minority modernizr module users and on the other side it breaks all lib checks for all other users. If there is a problem, ok - but it need to be fixed for all users, not the minority of modernizr users only. I do not see that this patch adds the unwished requirement to the modernizr module and I guess This code removal will only break things. There are reasons why this code has been added in past...
Comment #26
mducharme CreditAttribution: mducharme commented1. The lib checks would fall to the modernizr module. A dependency of the modernizr module will need to be added to navbar. I'm leaving this in needs work to get that done - thanks for catching that.
2. This module does require modernizr. Navbar shows an error on the status page if it is not installed.
3. I don't have the ability to create a 2.x branch. I already asked the question "Should a 2.x branch be started to integrate this change?". Maybe you could help push for that if you believe it's a good idea too.
This solution is meant to work towards your point that "it need to be fixed for all users, not the minority of modernizr users". The modernizr module's API is built to solve that need. I don't see another way of limiting the feature-set in a consistent way between contrib modules.
Comment #27
hass CreditAttribution: hass commented#2139345: Include Modernizr dependencies in hook_modernizr_info()
Comment #28
hass CreditAttribution: hass commentedI do not know why there is a compatibility problem, but fixing it looks like a lot better idea than forcing a integrating with these modernizr module.
Comment #29
mducharme CreditAttribution: mducharme commentedIf you don't understand why this is a compatibility problem then stop hijacking this issue. If you don't want to contribute anything constructive then walk away. This patch is fixing an issue for several people already.
Comment #30
hass CreditAttribution: hass commentedYou confirmed that this changes breaks the module for every non modernizr module user and it requires a dependency on modernizr module. The first is not acceptable and for the second a decission was already made several months ago - this module should not depend on modernizr module. See the duplicate case for jesses decission. Try to fix the bug you expierence, but do not make the module depend on modernizr module, please.
Comment #31
mducharme CreditAttribution: mducharme commentedI've added a support request to figure out whether or not modernizr is required. If it is not required then adding a dependency definitely doesn't make sense.
https://www.drupal.org/node/2351371
Comment #32
rupl@hass, I am considering adding a hard dependency on Libraries 2.0 which would drastically reduce the size of the Modernizr module codebase. Would that make a second dependency more bearable? You already have the Libraries dependency.
Or perhaps making a very small submodule inside of navbar to encapsulate all the Modernizr stuff would be possible? Then the dependency is limited to people who actively enable the Modernizr-related functionality.
Comment #33
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedI'd suggest the latter. I have to use modernizr module and having modernir loaded twice gives unpredictable errors.
Comment #34
hass CreditAttribution: hass commentedThe main questions that comes in mind here for me - are the library hooks used/implemented in a wrong way in navbar or modernizr module? Or are we victims of a libraries module bug? We shoulf first focus on this and once this can be answered we can start fixing in the right place. Just removing some code without understanding the root cause sounds wrong to me. Let's identify the root cause first. I have not read any bug analysis in this case yet. I think it need to be possible to define library hooks in both modules without a conflict.
I hope the root cause is not just a trivial issue like a module weight only as an example.
Comment #35
4aficiona2 CreditAttribution: 4aficiona2 commentedWhat is the current state of this issue? I still have troubles with Modernizr module version 7.x-3.3 (Modernizr v2.8.2) and Navbar module version 7.x-1.4. I also use a Aurora subtheme, generated with Aurora 7.x-3.4.
Does the current Modernizr dev-version 7.x-3.x-dev address this issue?
Comment #36
bisonbleu CreditAttribution: bisonbleu commentedI ran into a similar issue with OpenideaL, a distribution which uses Navbar. In short it appears that Navbar was blocking access to modernizr.js. Initially, the only fix was to disable Navbar.
Solution:
thanks!
Comment #37
4aficiona2 CreditAttribution: 4aficiona2 commentedThx bisonbleu, applying patch #12 worked for me too with my above mentioned setup.
Comment #38
mducharme CreditAttribution: mducharme commentedThe current state of this issue is that there is resistance to using the modernizr module as a dependency. The point of the modernizr module is provide a sane, consistent way for contrib modules to "share" the library and generate a modernizr installer that combines only the features that are required by each contrib. IMHO this makes sense and is in the spirit of the community. I've been met with resistance from one person so rather than argue I'm waiting on more feedback/support before investing more time into this.
Comment #39
hass CreditAttribution: hass commentedNo idea why nobody has an answer to #34.
Comment #40
bisonbleu CreditAttribution: bisonbleu commentedAs far as I'm concerned, it's a matter of context and perspective.
My installation requires modernizr (or parts of it) in at least 2 separate situations: navbar & an image grid that needs to be fully responsive. In the Open IdeaL ditribution, modernizr.js can be found at /profiles/idea/libraries/modernizr/modernizr.js. But for some unknown reason modernizr is not loaded; this is confirmed on the Satus Report page. Installing a second copy of modernizr at sites/all/libraries changes nothing. So I'm stuck.
Now, if I'm being practical (context), I have 2 short term solutions:
- Disable navbar to allow modernizr to be properly loaded.
- Leave navbar enabled, apply patch in #12 and install the modernizr module
Like most of us, I need something that works now - even if it's not perfect or ideal.
I mostly agree with what @hass is saying in #34. It does makes sense to investigate the implementation of the library hooks as well as the libraries module in search of the root cause of this issue. Any endeavour that makes navbar better is a good endeavour.
I also agree with what @mducharme and others are hinting at: let the modernizr module 'manage' modernizr.js for all modules that require it. I'm not an expert but it does seem to make sense. And wouldn't that standardized things a little? Assuming it does, then that sounds like a good ROI.
Summing up, both threads/contexts are legitimate. The challenge, IMHO, is to make them work in the same perspective.
Comment #41
mducharme CreditAttribution: mducharme commentedGood summary. Identifying the root cause as outlined in #34 is the first step and why this is still "needs work". The patch is just a temporary fix and should not be committed since it will break existing installs as I detailed in #14.
Comment #42
frobI am switching this back to active. It isn't in "needs work" because there isn't any idea as to what needs to be done.
I don't think that this module should depend on modernzr because the use case for modernzr is custom builds of the library. This module should be able to play nice with any other module that is defining a library by the same name. If there is a conflict then it is likely because something is wrong in modernzr, navbar, or libraries.
My (absolute) guess is the issue lies with modernzr. Modernzr is built around the concept that one would use a custom build of the lib. It should then use namespacing or another means to protect the lib that it is being used with.
Comment #43
hass CreditAttribution: hass commentedCNW because there is a invalid patch that was RTBC.
Comment #44
tr33m4n CreditAttribution: tr33m4n commentedTested with patch #12 on 1.4... Thanks, works as expected
Comment #45
hass CreditAttribution: hass commentedComment #46
PDonaghe CreditAttribution: PDonaghe commentedHaven't had a chance to fully test this, but at a minimum, the status report error goes away and my site still works.
Line 773 of navbar.module (7.x-1.5) reads:
'file' => 'modernizr-min.js',
Changing that line to read:
'file' => 'modernizr.min.js',
The modernizr module installation states:
Copy modernizr-X.Y.min.js to sites/all/libraries/modernizr/modernizr.min.js
Don't know if this was a change from past versions as I just started using it.
Seems to have worked on my end. If I come across any errors, I'll let you know.
Comment #47
tr33m4n CreditAttribution: tr33m4n commentedI also noticed this issue and completely forgot to mention. I changed line 773 in the same way @PDonaghe did and everything seems fine. On second thoughts however maybe it should be the library that's renamed to -min.js as that would fall in line with underscore etc
Comment #48
tr33m4n CreditAttribution: tr33m4n commentedI also changed line 796 in a similar way
Comment #49
hass CreditAttribution: hass commentedI think the issue is as follows. navbar defines a library with name
modernizr
. This name conflicts with modernizr module and maybe because of module weight reasons this get's overridden by the navbar module. I think we are doing something wrong in navbar module.Navbar module should not define a library with name
modernizr
. It should define a library namemodernizr.navbar
. As we require a very special build for navbar it should also have a different name in the file system. I propose something likemodernizr.navbar.js
andmodernizr.navbar.min.js
. This way we could add both filessites/all/libraries/modernizr/modernizr.min.js
(the full version from modernizr module) and the navbar version tosites/all/libraries/modernizr/modernizr.navbar.min.js
. In case the modernizr module is enabled navbar does not require the navbar version.I think this way we could allow users to use one or the other.
I also tend to say we should add
modernizr.navbar.[min].js
files to the navbar module itself. The build process is so complicated... this is really usability nightmare and I do not think any other module should usemodernizr.navbar
library.This is just brainstorming, I haven't tested this yet.
Comment #50
frobI agree with Hass' suggestion of including Modernizr in navbar. The Modernizr lib doesn't really have a good way to integrate so I wouldn't suggest we add the Modernizr module as a dependancy.
If we do not include the js lib in the navbar project then I would suggest we change the library directory.
sites/*/libraries/modernizr_navbar/modernizr.navbar.min.js
We can use modernizr_navbar as the libraries api info name as well. This should stop any conflict.
Any thoughts?
Comment #51
hass CreditAttribution: hass commentedWhy do you like to add a new library folder?
Comment #52
frobTo leave the modernizr directory alone for the modernizr module. It can be complicated to share the directory with two js libraries. This is made more complicated if someone wants to use npm to install the modernizr lib and grunt to build it.
Comment #53
jmking CreditAttribution: jmking commentedMaking Navbar depend on the Modernizr module is a reasonable move, IMO.
Duplicating the library for every module that might need it, however, is a silly suggestion - especially when the Modernizr module solves this exact problem.
At the VERY least, checking if the Modernizr module is installed before defining our own library seems like a perfectly reasonable solution. This module already implements hook_modernizr_info so it's already aware of the Modernizr module even if it doesn't have a hard dependency on it. See attached patch.
Comment #54
hass CreditAttribution: hass commentedHave you tested if this is a module weight issue or could be fixed by Modernizr module by using a different weight? Looks like lib name and folder name are still the old.
Comment #55
jmking CreditAttribution: jmking commentedNo, and I don't think telling people to go into the database and screw with module weights is a solution - especially since this works fine.
Like I said - this module is already aware of the Modernizr module and implements one of its hooks. Simply avoiding re-implementing the library if the Modernizr module is in use seems like the simplest, least disruptive solution.
Comment #56
hass CreditAttribution: hass commentedNobody said this. It is something the modernizr module can do with hook_install and hook_update. I just try to find a clean and reliable solution that works all times. The module check may work, but is not that clean like a module weight if this can solve the issue, too.
Comment #57
jmking CreditAttribution: jmking commentedI think what it boils down to is this: What is Navbar's job and what is Modernizr's job? Then the next natural question is why is Navbar trying to do a piece of Modernizr's job? There's clearly a need for Modernizr outside of Navbar - asking Modernizr to play module weight bingo with any other module that wants to use Modernizr defeats the entire purpose of the Modernizr module.
I still believe Modernizr should be a dependency of Navbar. However, this also works and resolves the conflict. Again, this isn't a problem with Modernizr - it's doing the job it's supposed to do. This is a problem with Navbar.
Comment #58
hass CreditAttribution: hass commentedThe root cause is that navbar is not shown for anonymous users (and maybe other roles) and therefore the navbar library dependencies no longer require the modernizr libary what removes the modernizr library from the page. As navbar has a higher module weight it currently wins and kicks out the modernizr library definition.
This patch should fix the issue in general manner for all times and for all upcomming conflicts like these.
Comment #59
hass CreditAttribution: hass commentedI'm happy that it does not. I have no need for Modernizr at all and like to save download size of this library.
Comment #61
ruplTested this and everything updated as expected. Hopefully this resolves the conflict between the two modules.
Comment #63
izmeez CreditAttribution: izmeez commented@hass Thank you for your patience in focusing for the root cause while expressing a different view on using specific modernizr scripts for navbar rather than using the modernizr module. A useful discussion. Thanks.