Defogging a bathroom mirror

I’m trying to shave and my wife’s taking a shower and the mirror fogs. If I rub my hand over a soap bar and then rub my hand over the mirror, it no longer fogs. Why? The mirror is still cool, so I assume water would still condense on it. Does the soap create a layer of insulation? Does water still condense but the soap keeps it from creating droplets?

It’s probably because there’s glycerine in the soap.

Back before windshield defrosters, etc,one would rub a layer of glycerine in the inside of the windshield to prevent fogging.

Problem was that you then had to keep a piece of toweling handy to wipe up the moisture that accumulated at the bottom of the glass,where it met the dash.