Loading a local JS library using --static-dirs instead of downloaded it from a CDN

Hi,

I am building an app (named Cartopluie) that require the library https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js.
In some case, this library is not downloaded (timeout). Reloading the page often solve the problem but not always. It is annoying for end user because the map build with ipyleaflet and ipywidgets failed to load.
As workaround, I suggested to download this library and serve it along the app directly using --static_dirs:

panel serve cartopluie.py --static-dirs assets="./assets"

In my app, I use at the begining:

pn.config.js_files = {
    "requirejs": r"/assets/require.min.js",
}

Panel is serving Cartopluie.py at http://localhost:5006/cartopluie

require.min.js is never found at http://localhost:5006/assets/require.min.js (404 GET /assets/require.min.js (127.0.0.1) 0.39ms).

What is the problem ? Is this solution would eventually works ?

Thank you,

What does the directory structure look like? You placed the assets directory alongside cartopluie.py and it contains the require.min.js file?

Hi,
Yes, here below the structure of the directory:

.
├── assets
│   └── require.min.js
├── cartopluie.py
├── class_antilope_rejeu.py
├── class_archives.py
├── class_arome_rejeu.py
├── class_data.py
├── class_header.py
├── class_player.py
├── class_popup.py
├── class_quadrant_tr.py
├── class_rejeux.py
├── creators.py
├── functions_interactions.py
├── functions_plot_bokeh.py
├── interface_tools.py
├── laucher.sh
├── map_control.py
├── parrallel_threads.py
├── require.min.js
└── svg_css.py

2 directories, 20 files

cartopluie is launched with the launcher.sh which contain the command:

panel serve cartopluie.py --admin --profiler snakeviz --global-loading-spinner --args debug --static-dirs assets="./assets" --admin-log-level debug

When Panel is serving the app I got these message:

Tue, 09 Dec 2025 14:56:39 - Debug : Making the app servable ...
Tue, 09 Dec 2025 14:56:43 - Debug : Serving the app now ...
2025-12-09 14:56:43,375 404 GET /assets/require.min.js (127.0.0.1) 0.69ms
2025-12-09 14:56:43,565 404 GET /assets/require.min.js (127.0.0.1) 0.30ms
2025-12-09 14:56:43,726 WebSocket connection opened
2025-12-09 14:56:43,726 ServerConnection created

Thank you,

@Marc helped me solve a js issue by using pn.extension

pn.extension(js_files={"plotly": "https://cdn.plot.ly/plotly-2.31.1.min.js"})

Maybe this might help?