JavaScript

  • Files MUST be stored in module's js directory.
  • JS files MUST be named as a module name with underscored replaced by dashes. E.g, my_module => my­-module.js.
  • More specific JS files SHOULD be included separately and named with .my-feature suffix. I.e. my-module.my-feature.js.
  • Use the following template as a scaffolding code:
/**
 * @file
 *
 */

/*global jQuery, Drupal*/

(function ($) {
  'use strict';
  Drupal.behaviors.my_module = {
    attach: function (context) {

    }
  };
}(jQuery));

Please refer to RFC2119 for meaning of words MUST, SHOULD and MAY.

All donations are forwarded to Drupal Association.

Drupal is a registered trademark of Dries Buytaert.