Of course I think about optimization when writing code, sometimes you can make the things a little better and other times you put a TODO if the code is a big mess.
In my company we have a document called Refactor and we put things to make better, to decoupling, integrate third party libraries and so on.
I think it's important to make nice functionalities but it's so interesting to make things faster and optimization when times allow.
Well at the moment it's all manually, we have some TODOS not in the refactor. The document at the moment it's in google drive and we are puting Frontend or Backend behind the title for know if is for one or another.