We're happy to announce the addition of several JavaScript-related tutorials to our Drupal 8 Theming guide.
- Load JavaScript in Drupal with Drupal.behaviors helps you learn how to make your custom JavaScript available after the DOM is fully loaded.
- Wrap Your Custom JavaScript in a Closure will help teach you about anonymous closures and immediately invoked function expressions.
- Use Drupal.theme for HTML Markup in JavaScript will teach you how theme functions work in JavaScript.
-
String Manipulation in JavaScript covers the JavaScript
checkPlain
andformatPlural
utility functions. - Use Drupal.t() for Translatable Strings in JavaScript so you can make sure any strings you add to the user interface can be localized.
- Use Server-Side Settings with drupalSettings in case you need to pass any dynamic values from PHP to your JavaScript.
- Standardize Your JavaScript with ESLint will help make sure your code meets Drupal's evolving JavaScript coding standards.
These tutorials, along with our other tutorials on defining and attaching asset libraries will help you understand Drupal's JavaScript API and help you make sure your custom code follows the established best practices.
If there are other topics related to JavaScript in Drupal you'd like to learn about please reach out. I'm always interested in hearing about the interests of our members.
Add new comment