Skip to content

Instantly share code, notes, and snippets.

@jamiemagique
Last active March 18, 2016 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiemagique/44a8f8f4702a219e9cf9 to your computer and use it in GitHub Desktop.
Save jamiemagique/44a8f8f4702a219e9cf9 to your computer and use it in GitHub Desktop.
Modernizr.load, example of loading in conditional js files with yepnope with correct path to the Drupal theme
Modernizr.load({
test: Modernizr.touch,
nope: Drupal.settings.basePath + Drupal.settings.customThemeSettings.pathToTheme + '/js/vendor/FILENAME.js',
complete : function () {
// Run the function after the scripts have downloaded
doSomethingFunction();
}
});
function doSomethingFunction() {
// Code to go with conditional loading
}
function THEMENAME_preprocess_page(&$variables) {
// Add custom settings
drupal_add_js(array(
'customThemeSettings' => array(
'pathToTheme' => path_to_theme()
)
), 'setting');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment