Implementing the Modernizr Test API within a module or theme
Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites
The Modernizr Drupal module provides a Test API which allows site admins to generate a custom build which contains all the features needed by modules and themes enabled within a Drupal site. This API is very simple, and implementing it means you'll be making life easier for any user who uses both your module/theme and the Modernizr module.
You can read the full docs within the official modernizr.api.php file, but here are a few samples:
How to implement within a module
Implement hook_modernizr_info()
in your module:
/**
* Implements hook_modernizr_info().
*/
function mymodule_modernizr_info() {
$tests = array();
// My Module relies on media queries.
$tests[] = 'mq';
return $tests;
}
How to implement within a theme
Themes should implement the dependencies within the .info
file:
modernizr[tests][] = flexbox
Alternatively, you can implement hook_modernizr_info_alter()
but we feel that the .info
method more closely aligns with normal themer workflow and domain knowledge.
List of modules/themes that support Test API
Once you implement this API, feel free to update this issue: #1914478: [meta] Provide Modernizr integration for other contrib modules
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion