In terms of performance, what's the difference between using the built-in UI and scripting your own UI?

I’ve been noticing that the built-in UI leads to a lot of lag in my game. So I was wondering if scripting the UI would be a better alternative or not. Would it make a difference performance- wise?

That is extremely vague. The same way you can badly code a database query, that will take 5+min to return the result and a good way to code it so it takes the least amount of time to return. All depends on your skills, needs, and optimisation you apply.

Unity UI was made to be used by people that don’t want to invest lots of time creating their own UI. T hus it is very generic. This requires a bit more work for those wanting custom UI elements. As for performance, i think the devs made it as optimised as it is possible for generics.

On the other hand, a cutom UI will better answer your needs, but has higher chances of bugs, lags and lack of proper optimisation.

It’s pratically impossible to know which better answers your needs without actually knowing said needs.