tags:

views:

285

answers:

0

I came across a weird behavior with jQuery. After minifying all my scripts, jQuery plugins do not work. jQuery object and its api are still available, but none of the extensions that were added after jQuery is able to be invoked. I tested and found that these extensions are still present until the dom is created. I created a simple extension:

jQuery.fn.test = function(){console.log('hey!');}

Then I invoked it from other scripts that are added after that extension

jQuery().test();

and it worked every time. But when the DOM was ready, page had loaded, I could not call this method again from the Firebug console. The console complained that:

TypeError: jQuery().test is not a function

Has anyone come across this behavior? My hypothesis is some method call in a jQuery.ready() bubble is somehow stripping the extensions. But I'm not sure what could cause such a behavior. Would injecting jQuery to a page that already has it strip out extensions?

EDIT: I found the cause of the problem. jQuery was indeed being injected a second time. Kind of weird that this never used to cause a problem before minification.