DEV Community

Aaron Gong
Aaron Gong

Posted on

3 2

Caveat

There could be a potential web performance issue

If you have 3 of the same custom components in your app, and the custom component has huge JS library.

  st.subheader("Component Test")
  rv = my_component(name="NameViteVanilla", key="K1", config=config, nodes=nodes, edges=edges)
  my_component(name="NameViteVanilla", key="K2", config=config, nodes=nodes, edges=edges)
  my_component(name="NameViteVanilla", key="K3", config=config, nodes=nodes, edges=edges)
Enter fullscreen mode Exit fullscreen mode

You could end up loading the library 3 times (see image below). Ouch!

Image description


Seems like the multiple reload of JS code also happens if streamlit-aggrid is used.

Code snippet below displaying 3 grids

grid_data1 = AgGrid(titanic_data, key="ag1", gridOptions=gridOptions)
grid_data2 = AgGrid(titanic_data, key="ag2", gridOptions=gridOptions)
grid_data3 = AgGrid(titanic_data, key="ag3", gridOptions=gridOptions)
Enter fullscreen mode Exit fullscreen mode

Snapshot of browser network calls, showing the aggrid related JS file being called three times...

Image description

I could be doing something wrong here though. So this definitely needs some investigation...

Image of Datadog

Master Mobile Monitoring for iOS Apps

Monitor your app’s health with real-time insights into crash-free rates, start times, and more. Optimize performance and prevent user churn by addressing critical issues like app hangs, and ANRs. Learn how to keep your iOS app running smoothly across all devices by downloading this eBook.

Get The eBook

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay