is it possible to include multiple jquery files like this one ?

(function ($) {
  Drupal.behaviors.mymodule = {
        attach: function(context) {
    //my code

I use this to include the files

drupal_add_js(drupal_get_path('module', 'mymodule') . '/js/mymodule.test1.js');
drupal_add_js(drupal_get_path('module', 'mymodule') . '/js/mymodule.test2.js');

both files are loaded but it seems that only the first is executed while test2 is ignored

can you help me with that ?


1 Answer 1


In Behaviors, behavior name don't need to be the same as module name. And it cannot be repeated, unless you want to disable earlier implementation.

If you separated your code, it means it's there to do different things. So just name them accordingly, like Drupal.behaviors.mymoduleDoSomething and Drupal.behaviors.mymoduleDoOtherThing.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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