• With the use of your plugin my site loads 457 kB uncompressed better messages CSS, site-wide. How to improve that?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Andrij Tkachenko

    (@andrijtkachenko)

    Hi,

    457 kB is the size of the file on disk, not what actually gets transferred. That CSS compresses down to about 54 kB with brotli, or 60 kB with gzip.

    If your site is really sending 457 kB, compression is not enabled on your server. Open DevTools → Network, reload, find bp-messages.min.css and compare the Transferred column with the Size column. If both show ~457 kB, nothing is being compressed — and that affects every CSS and JS file on your site, not just this one.

    Enabling gzip or brotli is done at the server level (nginx, Apache, your caching plugin, or your CDN). Your host can turn it on for you if you are not sure where.

    I cannot make that file any smaller. It covers the whole messenger interface — conversations, composer, file uploads, emoji picker, settings— and there is nothing in it to strip out. Compression is what brings it down to a reasonable size.

    The file loads on all pages because messenger elements can show up anywhere. The browser caches it after the first page, so it is one download per visitor rather than one per page.

    Thanks!

    Thread Starter locker17

    (@locker17)

    I checked it with dev tools and you are right, I get the CSS file with 60kb something. I cant remember on which page or when I saw the uncompressed file with around 450kb unfortunately.

    Anyway, the bp-better-messages-free.min.js file is 1.68 MB in size and this is the much bigger part. I checked, this file is loaded everywhere even on non message pages. The message notification bell?

    1.68 MB of JavaScript has to be parsed and compiled on every page load so this is an issue.
    Does the plugin support a lightweight launcher — a small stub that renders the floating bubble and only fetches the full bundle when a user opens a conversation?

    Plugin Support Andrij Tkachenko

    (@andrijtkachenko)

    Hi,

    You are right that the JS loads on every page. It is there for the unread counter and new message notifications, which can appear anywhere on the site.

    There is no lightweight launcher stub at the moment, the main bundle loads upfront. The heavy parts are already split into separate chunks that only download when actually used: calls, the file uploader, image editor, emoji picker, lightbox, HEIF conversion and sounds. What is left in the main bundle is the messenger core.

    Compressed it is roughly 400 kB over the wire rather than 1.68 MB, and it is cached after the first page. But you are right that parse and compile cost is paid on every page load, and compression does not help with that.

    If you only need the messenger on certain pages, you can unload it elsewhere:

    add_action( 'wp_enqueue_scripts', function () {
    if ( is_singular( 'post' ) ) {
    wp_dequeue_script( 'better-messages' );
    wp_dequeue_style( 'better-messages' );
    }
    }, 100 );

    Adapt the condition to match your site. On pages where it is unloaded the unread counter and new message notifications will not work.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.