add loop to event loop instead of function loop this way it doesn't hold...

... the js thread

I'm not actually sure if this exposes a problem right now, but it's potential. I saw it while I was in here and decided to clean it up.