Luca Lusso Modernizing Drupal 10 Theme Development -

Luca smiled. “I stopped theming Drupal like it was 2015. I started theming it like it’s a modern React app—but without the complexity. It’s just Twig, ES6, and a proper build pipeline.”

He replaced it with a modern, lean setup. He wrote a custom theme.libraries.yml that imported a single ES6 entry point: luca lusso modernizing drupal 10 theme development

He showed the client a preview. The carousel that used to stutter on scroll now ran at 120fps. The CLS (Cumulative Layout Shift) score went from 0.45 to 0.02. Luca smiled

global-scripts: js: dist/scripts/index.js: preprocess: true, minified: true dependencies: - core/drupal - core/once No more $(document).ready() . He used the new once() library to prevent rebinding and wrote vanilla JavaScript: It’s just Twig, ES6, and a proper build pipeline

import fetchData from './api.js'; document.querySelectorAll('[data-dynamic-counter]').forEach((el) => once('counter', el).forEach(async (element) => const data = await fetchData('/api/stats'); element.textContent = data.views; ); );