holoviz/panel

Panel does not correctly separate the required frontend assets of distinct served apps

Open

#5,598 opened on Oct 9, 2023

View on GitHub
 (5 comments) (0 reactions) (0 assignees)Python (615 forks)auto 404
good first issuetype: docs

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)
  1. access http://localhost:1234/simple - it looks okay (I guess).

  2. access the other app using the codeeditor at http://localhost:1234/editor - now the ACE editor JS is loaded (as it should)

  3. 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':

2023-10-09-141357_1802x288_scrot

the 'editor app' assets: 2023-10-09-141427_1482x283_scrot

'Simple' app, after accessing the second app at least once: 2023-10-09-141445_1392x282_scrot

Contributor guide