If you are using AMD, jQuery is sent to the function on line 22; if you're using a jQuery global, it's done on line 28. I just took the entire script and sent it to another function (that's what factory is), tested for AMD, and then called factory the appropriate way.