Extending $(document).ready() core function
Hi folks,
I have visited
an article by Ben Nadel regarding extending jQuery core functions and need an approach for one of my problems. I have posted the question in Ben's article, but reposting it here for the benefit of people who might face similar problem and also for a consolidated solution.
Here is my problem:
I'm working in a very huge jQuery based project. Functionally, everything is almost done, but now I have few generic requirements to be implemented across all screens. For this, instead of changing all .js files (which are around 500 in number), I was thinking to override $(document).ready function. Do you think this will be a good idea? I think rework would be less, but am not sure of side effects. What do you say?
Here's my implementation:
(function() {
var originalReady = jQuery.fn.ready;
$.fn.extend({
ready: function() {
console.log('custom ready');
originalReady.apply(this, arguments);
}
});
})();
Please let me know your valuable inputs.
Regards,
Krishna.