0

This question already has an answer here:

What is the best way to add javascript to Drupal theme now that drupal_add_js is gone?

I want to use specifically jQuery ui animate, which I suspect is in Core, but I cant find out how to add it to my theme.

marked as duplicate by Bala, Free Radical, Letharion, Anil Sagar, Mołot Mar 24 '14 at 8:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

Use the following function in template.php of your theme.

function MYTHEME_preprocess_page(&$vars, $hook) {
  $path = drupal_get_path('theme', 'MYTHEME');
     // Render the main scripts file.
  $local_js = array(
    '#attached' => array(
      'js' => array(
        $path . '/js/scripts.js' => array(
          'group' => JS_THEME,
          'weight' => 9999),
      ),
    ),
  );
  \Drupal::service('renderer')->renderRoot($local_js);
}
0

If you'll look at seven theme you'll see a note saying that libraries should be attached in hook_page_alter. I have similar issue https://drupal.stackexchange.com/questions/106842/whats-the-proper-way-to-load-themes-libraries

Not the answer you're looking for? Browse other questions tagged or ask your own question.