Skip to content

Instantly share code, notes, and snippets.



Created Jul 30, 2020
What would you like to do?
Add a js to a specific page from a module in Drupal
function mymodule_preprocess_page(&$variables) {
if (isset($variables['node']) && $variables['node']->type == 'book') {
// Add js
drupal_add_js(drupal_get_path('module', 'mymodule') . '/mymodule.awesome.js');
$variables['scripts'] = drupal_get_js();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.