Panel does not correctly separate the required frontend assets of distinct served apps
#5,598 opened on Oct 9, 2023
Repository metrics
- Stars
- (5,722 stars)
- PR merge metrics
- (PR metrics pending)
Description
ALL software version info
Panel 1.2.3
Description of expected behavior and the observed behavior
When I serve multiple apps, I expect that only the JS / CSS that is needed for an app is served to the frontend when a user accesses the app. However, it seems like the list on loaded/needed assets is somehow "shared" between apps.
Now e.g. if I use the CodeEditor in app A, but do not use it in app B, still the assets for CodeEditor are loaded when accessing app B.
Complete, minimal, self-contained example code that reproduces the issue
Launch a panel server with these two apps:
import panel as pn
pn.serve({
'editor': pn.widgets.CodeEditor(filename="test.md", value="hello test"),
'simple': pn.widgets.StaticText(value="hello world"),
}, port=1234)
-
access
http://localhost:1234/simple- it looks okay (I guess). -
access the other app using the codeeditor at
http://localhost:1234/editor- now the ACE editor JS is loaded (as it should) -
reload/open new tab with
http://localhost:1234/simple. Now the ACE Component is loaded, even though it is clearly not needed for this app
I think this is quite problematic for use-cases like ours, where panel is used to serve a possibly large number of completely unrelated apps that can have various different widgets. It seems like in the worst case, panel will send all the JS for all of the widgets used anywhere in some app - which is wasteful and inefficient.
Screenshots or screencasts of the bug in action
'Simple' app, before loading 'editor app':
the 'editor app' assets:
'Simple' app, after accessing the second app at least once: