Last active
March 18, 2016 16:04
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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