If you're doing a behavioral experiment online with Gabor patches, participants have to see a lot of them. That means they have to download a lot of images. Instead of that, why not generate the images on the client side? That's what this function does. See it live here.
There's also a web page with two sliders that show how fast the generation is by updating the parameters of the Gabor patch with each value change.