I have the following coffeescript file that works, except for the fact that when the images take some time, the download is done before the images are loaded, and then it does not have the desired effect:
ready = -> jQuery -> $('.box').find('img').each -> imgClass = if @width / @height > 1 then 'wide' else 'tall' $(this).addClass imgClass return return $(document).ready(ready) $(document).on('page:load', ready)
How to run my function only after loading the whole window?
My best attempt so far looks like
window.onload = -> $('.box').find('img').each -> imgClass = if @width / @height > 1 then 'wide' else 'tall' $(this).addClass imgClass return return
but that will not work. I also tried several other possibilities, but I can not understand what is wrong.
My question is different from this , because I do not want to wait until all the coffee houses are completed, I want to wait until all the images in my web page are loaded.
source share