React application and compiled assets question


I need some assistance regarding the assets-raw/compilation functionality.

We have included a React application (~2MB minified) in the backend, for registered users.
The application:

  1. updates almost daily
  2. It’s already minified,
  3. We don’t want it to be included in the compiled assets or available in the public folder (it’s meant for registered members only)
  4. We want it to load as fast as possible, avoiding the delay of the on-demand “raw assets” router.

We currently load the App from our sprinkle like this:
<script src="{{ assets.url('assets://myapprelativefolder/...

How can we optimize the template code to a) exclude the app from the asset compilation, and b) have a static link to it avoiding the locator service?


Difficult scenario to optimise for since authentication is required. There definitely are optimisations that can be made here, but not anything that is a part of UF (I’ll factor this scenario in v5 planning though, authenticated/permission-based static asset access is a fairly common requirement I’ve noticed).

As a first step, I recommend doing some profiling. It’ll help you identify where the biggest gains might be made, and where caching (be it via the cache service or with a static variable that exists only during the request lifetime) might be of help.

To exclude the app from asset compilation, you’ll need to move it to a different folder.

As for a static link, I’m not sure if there is anything that exists right now. That said, you can assemble the link yourself. A TWIG helper would keep things cleaner.

1 Like

Thank you for the detailed reply.

If we move the App to a different folder, outside assets, but still in our sprinkle, can we statically link to it?

If not, the only choice left is to move it to the public folder ourselves.