Include node specific JS/CSS in Drupal

function YOURTHEME_preprocess_page(&$variables) {

  //add assets for specific node 
  if ($variables['node']->nid == 12781) {
    drupal_add_css(drupal_get_path('theme', 'YOURTHEME') . "/css/foo.css");
    drupal_add_js(drupal_get_path('theme', 'YOURTHEME') . "/js/bar.js");
  }  
}
Published
Categorized as Drupal

Leave a comment

Your email address will not be published. Required fields are marked *