Introducing pre-compiled JS assets for self-hosters

david
Thu, 31 Jul 2025 16:25:05 +0000
Announcements

Discourse now publishes pre-built JavaScript assets, which will significantly speed up installation and updates, especially for servers with limited resources.

Compiling and optimizing JavaScript assets has always been one of the most resource-intensive parts of running Discourse. As our codebase and the JavaScript ecosystem have evolved, this process has become even more demanding.

In our tests, these changes reduce the asset-build time on a 1GB RAM Digital Ocean droplet from 45 minutes to just 3 minutes.

How does it work?

On every commit merged to main, a GitHub Actions workflow builds and bundles the assets into .tar.gz files (one for production, one for development). These bundles are published via GitHub releases in a dedicated repository. We ensure assets are published before any commit moves to tests-passed.

When building your own site, Discourse now checks for a matching pre-built bundle and downloads it. Plugins are then built on top. If no bundle is found or there’s an error, Discourse falls back to building from source.

Does this impact end-users?

No. Assets are still served to end-users from your own server / CDN.

Can I opt out?

Yes! If you prefer to build your own assets and have a sufficiently powerful server, set DISCOURSE_DOWNLOAD_PRE_BUILT_ASSETS: 0 in your app.yml file.

What if I’m running a forked or patched version of Discourse?

Asset bundles are named by commit hash. If you’re running a fork, no bundle will be found and assets will build from source. If your Discourse copy is patched (i.e., the git working tree isn’t clean), Discourse will not attempt to download a bundle.

What about other asset-related build steps?

Currently, this optimization applies only to core JS assets. In the future, we may expand it to some plugins and other steps like gz/brotli compression.

What about the stable branch?

Pre-built assets for the stable branch will be published starting with the next major version bump, planned for August 2025.

30 сообщений - 10 участников