I have added a custom favicon to my web app using st.set_page_config(page_icon=“logo.png”). I was observing the app behavior in the network tab of inspect page and I noticed the favicon was loading each time I interacted with the UI.
I have also deployed my app on render where things are a little slower compared to localhost. As the loading was a bit slower, when I interacted with input widgets the favicon would be replaced with the default streamlit icon for about a second and come back to the one I have set later on.
How can I fix it? You can observe this behavious in my web app calcthing.onrender.com.
Without seeing your code, the only thing that comes to mind is to put the st.set_page_config
call at the very beginning of your script app.
st.set_page_config
checks that it is the first streamlit command, but it does not check that it is the very first command in the script. For example, these two snippets will work as streamlit apps, but the first one won’t update the favicon after some time:
:
sleep(10) #<-- Show's the default streamlit favicon
st.set_page_config(page_icon="logo.png")
:
st.set_page_config(page_icon="logo.png")
sleep(10) #<-- Show's the updated favicon
Thanks for responding, the code is quite big so I don’t want to share it here, but the code is on github here: CalcThing/main.py at master · FrostedVolcano/CalcThing · GitHub
I do have the st.set_page_config at the begining, but I don’t have any sleep function added to it.
I used sleep
to mimic some slow process taking place before the st.set_page_config
call.
On the initial loading of the page, I do see for a second the Streamlit logo before loading your own. Interacting with widgets sometimes resets the favicon but sometimes it doesn’t… not sure what is the trigger.
Another idea is to resize the favicon to 32x32 (or something small like that) so it takes a shorter time to load. But I agree that the app requesting and reloading the favicon at every interaction is not ideal. That could be a good feature request to open on GitHub.
Nevermind that idea, your logo is already pretty small.