Yew has optimization recommendations regarding this: https://yew.rs/docs/advanced-topics/optimizations