"batch.js" - is it possible reduce its size and optimize rendering time?

Hi Confluence developers,

I am working as a performance engineer with 4-nodes Datacenter Confluence instance.
I’ve already created a support ticket for my question but was re-directed here by support team.

Google lighthouse reports(see screenshot from below), that “batch.js” may delay rendering page and potential saving can be up to ~1s.

Additionally, “Coverage” tool from Chrome devtools shows, that 73.2% of “batch.js” is unused.

So, is it something that can be fixed in order to reduce rendering time ?
Do you already have similar requests from other users ?

Well… ok… so… there are a couple of things you can do to optimise, but please do not get your hopes up. First, the batch.js output is a relic from an ancient past where the static resources were optimised differently than they are today. You can thank Microsoft / Internet Explorer for that.

The web resource manager, or page assembly manager, first determines which static assets need to be loaded based on the web resource context. Afterwards it will look at (shared) dependencies and create batches and super batches. You cannot change this process, and Jira/Confluence will continue to create these batches for the bulk of the static assets (either native assets, or other apps installed).

For your own app, you can do something. For instance, you can make use of the excellent atlassian-webresource-webpack-plugin.

If you combine this with webpack optimisation, and more specifically lazy loading (using the import() method provided by webpack), you can actually make sure that your app static code is not going to further increase the batch.js as it will only contain the webpack runtime and a very minimal boot loader for your app. But that does require that you organise your code in a way that it is bundled correctly by webpack and that you use lazy loading strategically.

7 Likes

For your own app, you can do something. For instance, you can make use of the excellent atlassian-webresource-webpack-plugin

Thanks for a tip.
I am running a non-customized vanilla distribution with several custom plugins. How should I use atlassian-webresource-webpack-plugin without rebuilding entire Confluence ? Please, a bit more details.

Ah ok, sorry, I assumed you were developing an app, as this is the developer forum. Unfortunately, the atlassian-webresource-webpack-plugin cannot be used on existing installations or app binaries. It has to be implemented by the app developer.

The only way to optimise your Confluence DC instance, is to look at using CDN and aggressive caching. There is no way to limit the bundle size of binary versions of apps and/or host products (like Confluence).

4 Likes