JQuery best practice, using $(document).ready inside an IIFE?
No, IIFE doesn’t execute the code in document ready. 1. Just in IIFE: (function($) { console.log(‘logs immediately’); })(jQuery); This code runs immediately logs “logs immediately” without document is ready. 2. Within ready: (function($) { $(document).ready(function(){ console.log(‘logs after ready’); }); })(jQuery); Runs the code immediately and waits for document ready and logs “logs after ready”. This … Read more