The admin config page should report the name of the file in use as well as the directories that are scanned for possible candidates.
This will hopefully make it easier to understand issues with missing tests due to the inclusion of a wrong file.

Original report
In my configuration > development > Modernizr > rebuild Modernizr page I get a message saying that the load test is missing from my Modernizr build. I also have a strange entry at the end of my tests list labeled: "load: No description available."

I've cleared my site's cache, downloaded a new modernizr build and even removed the module and installed it again without any luck. This issue only appeared when I updated from 3.2 to 3.3. I can duplicate the issue on all of my testing servers but when I try to duplicate it on a fresh Drupal install everything works just fine. Any idea what might be going on here?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pedrosp’s picture

It seems that the yepnope.js component is deprecated: https://github.com/SlexAxton/yepnope.js#deprecation-notice

For these reasons, we're also not going to include yepnope in the next version of Modernizr as Modernizr.load.

Still struggling how to deal with that , though...

johns996’s picture

So the original load, which is yepnope, is the thing the module is checking for? And the second "load" that is listed on my screen is the new version of Modernizr's load? Is there even a new version of load? I know when I'm creating the build to download I'm definitely checking the "load" option to include that functionality.

The Mad Martian’s picture

this is due to how modernizr module gets what tests are available from the js library.
opening up modernizr.js I can see that each test is separated with a hyphen ( or minus).
The very last test in this list is load and ends without a hyphen.
adding a hyphen to the end of the test list within Modernizr.js makes Modernizr module report load is present and available.

I don't know much about the inner workings of the module but the function which looks through the test list has to have a rule applied to not expect a hyphen at the very end of the list

/*edit*/
I will provide examples of changes
Root directory
>
*/sites/*/libraries/modernizr/modernizr
Before fix

/* Modernizr 2.8.3 (Custom Build) | MIT & BSD
 * Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransitions-history-inputtypes-svg-svgclippaths-touch-printshiv-cssclasses-addtest-teststyles-testprop-testallprops-prefixes-domprefixes-elem_details-load
 */

After fix

/* Modernizr 2.8.3 (Custom Build) | MIT & BSD
 * Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransitions-history-inputtypes-svg-svgclippaths-touch-printshiv-cssclasses-addtest-teststyles-testprop-testallprops-prefixes-domprefixes-elem_details-load-
 */

but a fix should be made to the part of the modernizr module which parses this list to not expect the hyphen on the end

rupl’s picture

Category: Bug report » Support request

Hi @johns996, could you please follow the issue submission guidelines and paste the URL of your Modernizr JS library? It's similar to the URL provided by Mad Martian in comment 3. I can't debug your support request without this URL. All issues of this nature are support requests until I can reproduce the problem, so I have re-classified this issue temporarily.

Regarding the deprecation of yepnope, this does not yet affect new Modernizr builds. http://modernizr.com still produces Modernizr 2.8.3 - which includes the same version of yepnope (aka Modernizr.load) as we have been using since early 2012. When modernizr.com updates to 3.0 then we will have an issue with yepnope. I'm honestly not quite sure what to do about that yet but please move all thoughts regarding that topic to here: #2311603: Address policy on upstream support

johns996’s picture

rupl’s picture

Just for posterity, here is the link in the library (in case it is updated in the future)

/* Modernizr 2.8.3 (Custom Build) | MIT & BSD
 * Build: http://modernizr.com/download/#-fontface-multiplebgs-video-shiv-printshiv-mq-cssclasses-teststyles-load
 */
rupl’s picture

FileSize
217.07 KB

Ok I took the library you linked to and put it in my standard dev environment for the module. On a vanilla Drupal 7.31 install I see the following when I drop your library into sites/all/libraries/modernizr. It seems to work perfectly.

rupl’s picture

Also you can search the file you linked to for "yepnope" and it's definitely there, with 6 results appearing near the end of the file.

Question: are you having a problem with yepnope or are you just noticing the strange error on the Drupal admin UI?

johns996’s picture

Yepnope seems to work just fine. The only issue I've noticed is the error in the Drupal admin. It's fixable by adding a "-" after load in the second line, just as Mad Martian said. I pulled that out again so you can see the file as it was generated.

Edit: I created a fresh install of drupal and loaded the modernizr module and then put this modernizr build in it. I saw the same thing you did, meaning that everything seemed to work just fine and no errors in the drupal admin. However on all three of my other instances of drupal (production and two testing environments) I get the load missing error. My production/testing involves a large multisite (169 sites) with a collection of other modules running. I didn't go through each one to see if it was a module causing the issue or something with the multisite because the fix Mad Martian posed worked.

droppinshucks’s picture

I get the same error after updating from 3.2 to 3.3. The Mad Martian hyphen fix also works for me. I've only tested this on one site.

rupl’s picture

Version: 7.x-3.3 » 7.x-3.x-dev
Category: Support request » Bug report

ok. Thank you for confirming the bug.

Editing the Modernizr file is not a maintainable option, we definitely need to find the problem within the module. We probably just need to adjust the code that looks at the build URL. I'll take a look at this soon.

Kebz’s picture

FileSize
13.26 KB

I'm still getting this message inside my status report even though I've downloaded several versions each time.

Modernizr Tests You haven't created a custom build yet.
Modernizr works best with a custom build. Visit the Modernizr settings page to create one.

Once I click on the link (xxx .com/?q=admin/config/development/modernizr)
I get this warning message:

WARNING
You don't seem to have a custom build of Modernizr installed yet. This page will help generate one for you.

Attached is the .js file saved as a text file so I can upload here
modernizr.custom.16849.js

When I go to build, it generates and downloads with the word "custom" in the filename.

rupl’s picture

Hi Kebz, unfortunately like the other examples in this issue, I cannot reproduce the problem on a vanilla install of Drupal 7. I see that you have yepnope and it is being assigned to Modernizr.load within the JS file as expected. So you are building the file properly and if the JS file is appearing in your theme then you are ok to use it as-is. Sorry for the false warning, I have never figured out what is happening to others' installs.

Kebz’s picture

Thanks for responding @rupl

Is there a naming convention to be used properly? Because the report says it's not built.
So when we go to the Modernizr site, it takes us to their download page with pre-selected items based on the tests listed.

  • We then generate ... either a "minify" or a "non-minify" source
  • Download file
  • and this is what's produce (as an example)
  • >> filename: modernizr.custom.16849.js

According to these instructions (https://www.drupal.org/project/modernizr), it says to download filename "modernizr-X.Y.min.js", but my files are not getting the ".min" name inside the files I'm receiving. Am I missing a step somewhere??

Installation:

  • Download a Modernizr custom build
  • Copy modernizr-X.Y.min.js to sites/all/libraries/modernizr/modernizr.min.js
  • Enable the module

Also, according to the documentation here https://www.drupal.org/node/1913748, it says this

Missing tests/utilities
As of 7.x-3.3, the module will report when it cannot find required tests or utilities within your current custom build of Modernizr. The missing tests are highlighted red and display the word (missing) after their name.

However, I get this (as you mentioned) a "false warning" You don't seem to have a custom build of Modernizr installed yet. This page will help generate one for you. and nothing is appearing in red.

BTW, I'm a little confused here on what you wrote:

So you are building the file properly and if the JS file is appearing in your theme then you are ok to use it as-is.

What do you mean by "if the JS file is appearing in my theme"?? How do I know if it's doing what it's suppose to do?

Thanks in advance!

Kebz’s picture

I reviewed the code inside the file "modernizr.install" -- and it specifically says that we have to rename the downloaded file to "modernizr.min.js"
HOWEVER, even after renaming it, it is still giving me the error notice =\ sigh

// Modernizr not installed, Libraries API is installed.
// Supply instructions recommending Libraries module.
elseif (!$path && module_exists('libraries')) {
$description = t('Modernizr JS library cannot be found. Download it from !modernizr-site, copy it into !path and rename it to modernizr.min.js.',
array(
'!modernizr-site' => l(t('modernizr.com'), 'http://modernizr.com/download/'),
// !path has a hardcoded default because the libraries_get_path() function might not return
// the correct path when conditions lead to this block of code being executed
'!path' => (libraries_get_path('modernizr')) ? libraries_get_path('modernizr') : 'sites/all/libraries/modernizr',
)
);
$severity = REQUIREMENT_ERROR;
}

hass’s picture

I'd like to note one thing I have found in the module. Not sure if related, but let's say you run navbar and you place the navbar modernizr build in the libraries/modernizr folder with filenames navbar requires. Than modernizr complains two features are missing. Ok, download modernizr custom build and place in the sane folder.

Modernizr module finds the navbar build first and complains the correct modernizr js file is still missing, but it is inside the folder...

I think modernizr module should scan all files and check all for the features and than remember and add the one that has all features included.

Not sure if i opened a case for this bug in modernizr queue.

jiv_e’s picture

Kebz, if you have installed using drush there should be a modernizr-latest.js file in the libraries folder. Try to remove that. It worked for me.

Kebz’s picture

@jiv_e .. thank you!! That did the trick =)

You know, I did see that file in there, but didn't think nothing of it cause I thought the code is looking specifically for the other files. And strangely enough, I did change the file name of that to the requested filename "modernizr.min.js" -- but it was the copy on my local drive and then I uploaded ... anyhoo... all is good now... yay.. thanks again =)

jiv_e’s picture

If I understand right modernizr module search only for the first file it founds in the libraries/modernizr folder. When it founds the modernizr-latest.js it doesn't bother to search the right file.

rupl’s picture

Title: Modernizr load claims it is not in the build when it is » Module should prefer custom build if the file exists
Related issues: +#2395841: Need update to documentation? modernizr-latest.js?

I think that's the true nature of this bug and a quick search through issues didn't reveal anything with near as much discussion as this issue so I'm reclassifying it to deal with the bug.

aubjr_drupal’s picture

The module also can't find a modernizr script if another script named modernizr2.8.3.js is in the same directory. I left that old modernizr2.8.3.js script in the /libraries/modernizr director as a backup during testing, and it couldn't find modernizr.js until the backup was removed from the directory. Strange behavior.

berliner’s picture

I just spent more than an hour researching why modernizr would not work correctly on our production server, while locally and on all stage and testing servers it was working correctly. Turned that on prod we had a leftover "test" directory from earlier versions that contained the file `modernizr-1.7.min.js`. So I'm definitely in favour of using a custom build file if available.

In order to understand this kind of problem it would also be of great help if either the status page or the modernizr settings page would mention which file it is actually loading. I realise that this is something that can be found by disabling JS aggregation and looking at the loaded resources, but you usually don't want to do that on a busy production site just to get this kind of information.

rupl’s picture

I'm sorry that it caused you trouble. I like the suggestion to display the file which was found. That is simpler and less philosophical than "preferring" a custom build, which isn't technically possible. You can name the file many names as long as you follow a regex. However reporting the file name is very doable and I think is good info to display anyway.

I definitely wouldn't want to be responsible for making someone disable aggregation in production! ;)

berliner’s picture

Great news. Do you need a helping hand on this?

Should this be handled here or in a new issue?

rupl’s picture

Title: Module should prefer custom build if the file exists » Module should report which file it is using in admin config

That would be great! Just FYI I am leaving on my honeymoon in 4 hours so I might be slow to respond for a while. But I would be happy to accept a patch.Otherwise I can get around to it in April.

If you create a patch go ahead and do it here. I've updated the issue title to indicate new direction.

berliner’s picture

Happy honeymoon then!!!

I'll have the patch ready for your return ;)

berliner’s picture

Issue summary: View changes
berliner’s picture

Status: Active » Needs review
FileSize
2.45 KB

This patch adds information about the currently loaded file if any. If no file is found, a list with the scanned directories is also displayed.

I have also removed duplicate paths if the libraries module is used.

In the long term, I would actually propose to make the file selectable if multiple candidates are found. This should be pretty straight-forward using a dropdown and a variable setting. But that should probably go into it's own issue.

  • rupl committed 51a0d9e on 7.x-3.x authored by berliner
    Issue #2349193 by berliner, rupl, Kebz: Module should report which file...
rupl’s picture

Status: Needs review » Fixed

This patch is tip top! Thanks so much. It's committed to dev with your name attached.

I have some other housecleaning to do but I will stamp a new release soon.

berliner’s picture

Great!

rupl’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.