I have a js file called “app.js” that I store most of my javascript in so that it can be easily minimized.
I noticed that I’ve been wrapping each of the unique functions in:
$(document).ready(function () { ... });
There are about 10 functions wrapped this way in the file. Would it better for me to instead wrap the entire app.js file inside of the $(document).ready instead of each individual function?
I feel like I might have read to avoid abusing the document, but I may just be thinking of $(this)?
Are there any performance problems in what I’m doing?
There shouldn’t be any performance issues with this kind of approach, but in my opinion it looks ugly and hard to read.
What i suggest is to use just one
readyfunction to act as yourinitand then store functions outsideready, for example: