Question

I want to invoke an anonymous self-executing function, only when dom is ready, with the more memory-efficient technique. And also, I want to use locally-scoped versions of window and window.jQuery global Objects, for optimization (loading local scope it's faster than global).

So, it's this pattern correct?

;!(function(window, $) {
    $(function(){
        // your code here
    }); 
})(window,window.jQuery);

I'm not sure if I'm doing something wrong ...

Thanks in advance!

Was it helpful?

Solution

Would just look a little better IMO:

;(function(window, $, undefined) {
    $(function(){
       // your code here
    }); 
})(window,jQuery);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top