Frontend

Last updated on
2 June 2025

These are still being discussed: https://www.drupal.org/project/drupal/issues/3002762

Coding standards

When is this needed?

Changes to CSS or JavaScript

Details

There’s linters setup to make sure all of the CSS and JavaScript code follows Drupal coding standards.

Resources

https://www.drupal.org/node/2274223
https://www.drupal.org/node/2868114

BEM

When is this needed?

Changes to classes or CSS

Details

All new classes and selectors should take into account the BEM guidelines. Refrain from using overqualified selectors, for example, a.link should be just .link.

Resources

http://getbem.com/

Backwards compatibility

When is this needed?

Changes in preprocess functions, templates or CSS

Details

Most changes to markup or CSS will be considered as BC breaking. Drupal core Stable and Classy themes are backward compatible. Changes to non-backward compatible themes will be easier, thus should be preferred.

Resources

https://www.drupal.org/core/d8-bc-policy#themes
https://www.drupal.org/core/d8-frontend-bc-policy

Browser compatibility

When is this needed?

Changes to markup, CSS or JavaScript

Details

Drupal core promises to support a set of browsers. When making any changes to markup, CSS or JavaScript it is important to ensure that the change is compatible with all supported browsers.

Resources

https://www.drupal.org/docs/8/system-requirements/browser-requirements

JavaScript Transpilation

When is this needed?

Changes made to JavasScript

Details

All patches with changed files must include an ES5 transpilation of ES6 code.

Resources

https://www.drupal.org/node/2815083

JavaScript selectors

When is this needed?

Changes to selectors used in JavaScript

Details

When attaching JavaScript to markup, it should be done using either js- prefixed classnames or data-drupal-selector data attribute.

Resources

https://www.drupal.org/project/drupal/issues/2431671

Help improve this page

Page status: No known problems

You can: