Skip to content

Loading Modernizr In The Footer

Jim Reevior edited this page Aug 14, 2018 · 1 revision

Loading Modernizr in the Footer

By default, Modernizr is loaded in the site's <head> tag. This is for a few reasons.

  1. the html5shiv which is required for using HTML5 elements in <= IE8 must be executed before IE finds one of those tags in the HTML.
  2. Any styling hooks you have based on Modernizr's classes may cause a FOUC if Modernizr is executed lazily.

More info can be found on the Modernizr repo.

If there is a valid reason to load Modernizr in the footer and you have checked for all of the scenarios described in the link above, you can tell Modernizr to load in the footer of the site.

<?php
/**
 * Load Modernizr in the footer.
 */
function mytheme_r_modernizr_in_footer() {
	return true;
}
add_filter( 'r_modernizr_in_footer', 'mytheme_r_modernizr_in_footer' );

Welcome to Responsive!

Get started

Configuration

Build child themes

Sass

Javascript

PHP

Shortcodes

Templates

GitHub

Tasks

Contribute to the framework

Code Examples

BU Developer Resources

Clone this wiki locally