Modernizr Load

Hi!

I’m just getting started with Roots and I’m trying to integrate Modernizr.load, but I’m not sure what the best way to do that would be. I need to load some polyfills before loading scripts.min.js. Ideally I’d like to do something like the following, after loading jquery and modernizr.

Modernizr.load([
    // series of test here
    {
        test: window.matchMedia,
        nope: "path/to/polyfill.js"
    },

    "path/to/scripts.min.js" //this is the minified js file generated with Grunt
]);

What’s the best way to achieve this in my theme?

Cheers!

You can just create a new file where you load the polyfills and register/enqueue it after Modernizr and jQuery: https://github.com/roots/roots/blob/432493a9da8d2c4028d34e89170c5071c010b41e/lib/scripts.php#L32

Just a heads up, Modernizr.load has been removed from the latest version of Modernizr, since it is just a thin wrapper around yepnope. I would highly recommend just using yepnope directly, rather than having to update the code in the near future when Modernizr 3.0 comes out.

Thanks for the heads up!

Thanks! Your solution worked, but I also had to use wp_localize_script to pass the value of get_template_directory_uri() to my script.