optimizing-streamlit-performance

Optimize Streamlit apps by caching data and fragmenting UI components.

Updated Jan 31, 2026
One-click install
npx skills add https://github.com/Mahaboob26/NEXUS-TRUSAI --skill optimizing-streamlit-performance-mahaboob26
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: optimizing-streamlit-performance
Source: https://github.com/Mahaboob26/NEXUS-TRUSAI/tree/main/.agents/skills/developing-with-streamlit/skills/optimizing-streamlit-performance
Command: npx skills add https://github.com/Mahaboob26/NEXUS-TRUSAI --skill optimizing-streamlit-performance-mahaboob26

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Streamlit apps often suffer from slow interactivity due to unnecessary reruns and heavy content loading. This Skill teaches you how to reduce reruns, cache data, and render large dashboards more efficiently.

Core Features & Use Cases

  • Caching data and resources with Streamlit decorators to avoid recomputation.
  • Fragmenting UI with st.fragment to isolate expensive components.
  • Handling large datasets and live metrics with smart rendering strategies.

Quick Start

  • Identify heavy functions and wrap them with @st.cache_data.
  • For resources like database connections, use @st.cache_resource and copy-before-modifying patterns.
  • Break up complex UIs with st.fragment and conditional rendering to minimize work on each interaction.

Frequently Asked Questions about optimizing-streamlit-performance

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I speed up a slow Streamlit dashboard?

Improve Streamlit performance by caching data computations with @st.cache_data, caching resources like database connections with @st.cache_resource, and using st.fragment to isolate expensive UI components from full script reruns.

When should I use st.cache_data versus st.cache_resource in Streamlit?

Use st.cache_data for expensive data computations to return cached copies, and use st.cache_resource for global resources like database connections where returning the exact same object is required.

How do I stop Streamlit from rerunning expensive functions on every interaction?

Stop unnecessary Streamlit reruns by applying @st.cache_data to heavy functions and using conditional rendering alongside st.fragment to ensure only the required UI sections update.

What is the best way to handle large datasets in a Streamlit app?

The best way to handle large datasets in Streamlit is to cache loaded data with @st.cache_data and apply smart conditional rendering strategies to minimize recomputation during interactions.

Can I isolate expensive components in Streamlit to avoid reloading the whole dashboard?

Yes, you can isolate expensive components in Streamlit using st.fragment, which allows specific UI sections to rerun independently without triggering a full dashboard reload.

Why does my Streamlit app still run slowly after adding caching?

A Streamlit app might still run slowly if global resources are not cached with @st.cache_resource or if complex UIs lack st.fragment isolation, causing unnecessary conditional rendering and heavy content loads.