Why does my streamlit app take around 8 seconds to load at the beginning even though I'm not using large datasets?Is there a solution to reduce the initial loading time?

streamlit version=1.38

How are you measuring the “initial loading time”?

I didn’t used any external libraries, measured the app loading time by setting timer.

When do you start the timer and when do you stop it?

I start the timer as soon as the app begins loading in the browser and stop it once all the widgets are fully loaded and displayed

That is most likely just your code taking that long to run.

import streamlit as st
import pandas as pd
df = pd.DataFrame()
css = '''
        <style>
            [data-testid='stFileUploader'] {
                width: max-content;
                display:flex;
                flex-direction:column-reverse;
                align-items:flex-start;
                margin-left: 90px;
            }
            [data-testid='stFileUploader'] section {
                padding: 0;
                float: left;
            }
            [data-testid='stFileUploader'] section > input + div {
                display: none;
            }
            [data-testid='stFileUploader'] section + div {
                float: right;
                padding-top: 0;
                
            }
            
           [data-testid='stFileUploaderDropzone']> [data-testid='stBaseButton-secondary'] {
                margin-bottom: -1px;
            
            }
            [data-testid='stFileUploaderDropzone']>[data-testid='stBaseButton-secondary'] {
                text-indent: -9999px;
                line-height: 0;
            }
            
            [data-testid='stFileUploaderDropzone']>[data-testid='stBaseButton-secondary']::after {
                line-height: initial;
                content: "Choose file";
                text-indent: 0;
            }
              [data-testid='stFileUploader']>  [data-testid='stWidgetLabel'] > [data-testid='stMarkdownContainer'] {
                  display:block-inline;
                  margin-left:-90px;
                  margin-top:-60px;
                  
              }
              

        </style>
        '''
st.markdown(css, unsafe_allow_html=True)
uploaded_file = st.file_uploader("Upload a file:")

selected_task = st.radio("Choose Evaluation Type:", [ "Evaluate","Enn"], index=0, horizontal=True)
st.button("Submit")

this code takes atleast 2-3 seconds to load why ? Does plugins cause the issue

It takes less than a second in my pretty standard laptop. I am not sure what may cause the difference. Maybe poorer computer specs, different browser, different python…

could you give some tip to improve performance in streamlit app

Maybe try Chrome > Dev Tools > Lighthouse. Or Chrome > Dev Tools > Network.

Thanks! will try