Multi-page app load speed

I have a multi page app that I am finding has a slow initial page load speed.

My question - when the app is first visited, do all the callbacks from all the pages trigger, or is it just the callbacks from the currently active page that triggers? If they all trigger, is there a way to disable this?

There are 10 pages, all of which are pulling data from an AWS RDS db, and uploading it to a datatable component and a chart.

thank you

In my experience it is only the active pages that are loaded. You could easily check this yourself with a print statement when the callback is triggered.

2 Likes

Hi @anarchocaps

You can speed the load time if you also set suppress_callback_exceptions=True

app = Dash(__name__, use_pages=True, suppress_callback_exceptions=True)

If you exclude this, pages will automatically create a app.validation_layout for you under the hood, which can slow the load time. (More info here)

Note that if your page layouts are functions, it may still be slow, however this will be fixed in the next release (2.6.2) coming soon.

4 Likes

Thanks @AnnMarieW .

My layouts are currently functions in other modules, that I am importing into the module with the callbacks.

When the update arrives, will the update make using layout as a function the same speed as using app.layout directly, or will there still be a difference between the two of them?

thank you

Hi @AnnMarieW I’m wondering if the functional layouts was fixed? Couldn’t see anything in the changelog. I am seeing 2 seconds minimum for a layout function to run even with just one html.Div() and suppress_callback_exceptions=True. Running layout functions without dash_pages happens in millisecs. Can do a MRE if needed.

Hi @lex1

Yes, this was fixed in 2.6.2 but maybe now there is something else now that’s slowing things down? MRE is always helpful. Thanks.

Sorry was all on my end, just needed to reboot the dashapp to update the function!

1 Like

My question is regarding how the callbacks function when the app is first visited. Specifically, do all the callbacks from all pages trigger immediately, or is it just the callbacks from the currently active page that execute? I suspect that if all callbacks are firing upon the initial visit, it could be contributing to the slow load time.