I have a js file that contains my closure, this file is loaded before jQuery, let's say it can't be moved. How can I pass in or check for jQuery with a view to use it in the closure?

This is what I've got so far:

```
(function MyClosure() {

    var interval = setInterval(function() {
        if (typeof jQuery !== 'undefined') {
            doJqueryStuff();
            clearInterval(interval);
        }
    }, 500);

    function doJqueryStuff() {
        // Some stuff with jQuery.
    }
})();

```

It actually works, but is there a "better" way? I always think I'm doing something wrong whenever I use `setInterval()` for things like this, also the fact I am losing time in that 500ms.