When an input is focused, the requestAnimationFrame check loop should change CSS only when it is necessary.
So instead of repeatedly calling showPlaceholderIfEmpty() (which calls removeClass() or addClass() all the time) in the check loop, we should polling input.val() and call hidePlaceholder() or showPlaceholder() only when the boundary condition is satisfied.
When an input is focused, the requestAnimationFrame check loop should change CSS only when it is necessary.
So instead of repeatedly calling
showPlaceholderIfEmpty()
(which callsremoveClass()
oraddClass()
all the time) in the check loop, we should pollinginput.val()
and callhidePlaceholder()
orshowPlaceholder()
only when the boundary condition is satisfied.