Basic active buzzer to existing project guidance

A diode Flyback diodes and why you need them

However, I note you said:

So if it already works on a D1 Mini maybe it's OK, maybe it does not produce lots of high voltage crap. Only way to know is with an oscilloscope.