I try to optimize my pages by putting some async attributes on my scripts. It seems to break my javascript since $(document).ready is executed before the all scripts are loaded!
I saw that I can resolve my problem by putting $(window).load instead of $(document).ready but I was wondering if there is a better solution.
This solution trigger 2 problems in my case :
- I have to change all
$(document).readyand tell all the developpers to not use it anymore - The scripts will be executed after all images are loaded. My website has a lot of heavy images and I really need some scripts to be executed ASAP after dom is ready.
Do you have some magic tricks? Maybe putting all scripts at the end? use defer instead of async?