Skip to content

Instantly share code, notes, and snippets.

@simondahla
Created July 26, 2013 12:53
Show Gist options
  • Save simondahla/6088619 to your computer and use it in GitHub Desktop.
Save simondahla/6088619 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
/*####
Load in script only when a DOM element exists.
Use callback function to run
####*/
Modernizr.addTest('foo', $('.bar').length > 0);
Modernizr.load({
test: Modernizr.foo,
yep: 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js',
callback: function () {
//Run this when the 'foo' condition is met
$('.bar').console.log('I detected the "bar" class, loading in jQuery UI');
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment