When we added Gander performance tests to Drupal CMS, we uncovered several opportunities for improvements that benefit Drupal CMS users and the broader Drupal community. Our systematic approach to testing revealed optimization opportunities in both core and contributed modules.
This resulted in substantial performance gains and key insights for future improvement, which we’ll break down below.
Klaro Cookie Consent: From 200KB to Zero
One of our most notable findings involved the Klaro cookie consent module, which ships with Drupal CMS’s privacy recipe. Initial testing revealed that anonymous users were downloading over 200KB of JavaScript immediately after installation, with Klaro responsible for more than 90% of this load.
Through collaborative efforts with Klaro and Drupal CMS privacy track maintainers, two major improvements were implemented. First, the library size was reduced to around 64KB by optimizing the build process and removing support for outdated browsers. More significantly, Klaro now loads only when actually needed — for instance, when a site includes embedded YouTube videos requiring consent.
This optimization, implemented by Jürgen Haas (@jurgenhaas), resulted in zero JavaScript overhead for fresh installations. The solution leverages ECA (Event-Condition-Action), already included with Drupal CMS, to progressively change configuration without requiring custom modules.
Learn more:
- Issue #3491681: Library size optimization
- Issue #3493438: On-demand loading implementation
Coffee Module: Smarter AJAX Loading
Using Gander for performance testing and DDEV’s xhprof support, we discovered an unexpected issue with the Coffee module, which provides administrative search functionality. What would normally be a single page request was triggering an additional request and causing dozens of database queries to execute, even with warm caches. Further investigation showed that the module was making AJAX requests on every page load, regardless of whether the search feature was being used.
The solution was straightforward but impactful: we modified the module to only make its AJAX request when a user opens the Coffee search modal. This change has been incorporated into the latest release, improving performance for all sites using this module.
Learn more:
- Issue #3494208: Coffee module optimization
Navigation Module: Optimizing Menu Tree Queries
Our testing process uncovered that Drupal core’s experimental Navigation module was generating numerous unnecessary menu tree queries. While there was an existing issue to optimize menu tree rendering, we identified a simpler solution: implementing a dedicated render cache entry for the module. This reduced the number of database queries by 20 per page request by caching the navigation globally for the site instead of once per page through the dynamic_page_cache module.
As part of core, this optimization benefits not only Drupal CMS sites but all Drupal installations using the experimental module. The fix has been committed and will be available in the next Drupal core patch release.
Learn more:
- Issue #3493406: Navigation module caching implementation
Language Module: Catching Hidden Performance Issues
Another core module highlighted by our performance testing is the Language module. According to our tests, uncached database queries were executing on every page load. The queries no longer appeared after the module was removed from the Drupal CMS SEO recipe.
This led to the creation of a new core issue by Sascha Grossenbacher (@berdir) to implement proper query caching.
Learn more:
- Issue #3497957: Language module recipe removal
- Issue #3497333: Query caching implementation
Recipe Installation and Project Browser Improvements
While investigating out-of-memory errors in the Project Browser, we discovered that Drupal’s new Recipes API wasn’t taking advantage of Drupal’s bulk module installation optimizations. Instead, it installs modules one by one, bypassing existing performance optimizations for concurrent installation.
Addressing this issue promises to significantly improve the speed and memory efficiency of applying recipes.
Learn more:
- Issue #3498026: Recipe API optimization
Core Cache Backend Optimizations
During memory profiling of Drupal CMS, we identified potential optimizations for Drupal's chained fast cache backends. This demonstrates how performance testing of Drupal CMS can lead to improvements in Drupal core itself and enhance efficiency across all Drupal installations.
Learn more:
- Issue #3498193: Cache backend optimization
Additional Benefits Beyond Performance
Performance testing of Drupal CMS yielded benefits beyond optimization. Using Drupal’s PHPUnit test framework helped identify a major bug with Drupal CMS’s default front page redirect functionality — discovered within a few minutes of implementing the initial test coverage.
Additionally, because Drupal CMS depends on contributed modules, a new release can change behavior or introduce regressions. To catch potential issues before they affect end users, we recommended adding nightly testing against development versions of dependencies. Adam G-H (@phenaproxima) implemented the testing within hours of the issue being opened. It immediately began identifying regressions introduced in contrib modules before they could impact stable releases of Drupal CMS.
Learn more:
- Issues #3498193: Front page redirect bug
- Issues #3496652: Nightly testing implementation
Testing Today Shapes Drupal’s Tomorrow
Our performance testing initiative demonstrates the power of systematic testing in uncovering optimization opportunities across the Drupal ecosystem. These improvements extend beyond Drupal CMS, creating a ripple effect that enhances performance for hundreds of thousands of Drupal sites worldwide.
By increasing the review of Drupal CMS and the contributed modules it includes, we’re driving improvements to performance that benefit the entire Drupal community.
Get Involved
Want to learn more about performance testing in Drupal? Join us in making Drupal faster and more efficient for millions of users worldwide.
Here are resources to get you started:
- Check out issues with the Gander tag on Drupal.org.
- Review the Gander documentation for implementing performance tests.
- Watch the DrupalCon dive deep performance testing presentation by Janez Urevc.
- Watch Tag1 Team Talks: Gander Automated Performance Testing Demo with Nat Catchpole.
Image by Karl Egger from Pixabay