Created on 30 June 2023, over 1 year ago

To squeeze out maximum performance and to give Matomo another advantage over Google Analytics, it would be great to add support for Brotli compression if the module detects support.

I did a manual compression at maximum Brotli compression level and compared it with the matomo.js and matomo.bz files generated in /sites/default/files/matomo/:

Size comparison:

  • Uncompressed: 65842
  • Gzip compression: 21420
  • Brotli compression: 18638

That is about 13% less and it brings the tracking script below the size of the old GA3 script.

Decompression speed comparison:

  • Gzip - real 0m0,022s
  • Brotli - real 0m0,004s

That is more than 5 times faster!

I am no programmer, but looking at the code I guess a similar entry like the following needs to be added to the code:

          if (extension_loaded('zlib') && \Drupal::config('system.performance')->get('js.gzip')) {
            \Drupal::service('file_system')->saveData(gzencode($data, (int) 9, FORCE_GZIP), $file_destination . '.gz', FileSystemInterface::EXISTS_REPLACE);
          }
Feature request
Status

Active

Version

1.21

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024