deckerdev.com

Templates for quickly starting javascript behaviors (for Drupal)

Drupal 7:

(function($, Drupal) {

  'use strict';

  // Description
  Drupal.behaviors.nameOfBehavior = {
    attach: function (context, settings) {

      // Code here.

    }
  };

})(jQuery, Drupal);

Drupal 8 (ES6):

'use strict';

(function ($, Drupal) {

  // Description
  Drupal.behaviors.nameOfBehavior = {
    attach: (context, settings) => {

      // Code here.

    }
  };

})(jQuery, Drupal);