Why is jQuery.ready recommended when it’s so slow?

后端 未结 4 1870
眼角桃花
眼角桃花 2021-01-31 09:07

I have asked a similar question before but I never made my point exactly clear, or at least I think it’s such a relevant question that it’s worth to bring it up and see if anyon

4条回答
  •  执笔经年
    2021-01-31 09:17

    One advantage would be, that you are able to place the code anywhere in the page. In our case, we use a templating system in our CMS that stitches the page together from around 10 - 30 templates for the different parts (depending on complexity).

    Since you want the templates to work on any page they are used, you need to include the necessary Javascript in it. For those cases, the ready() function is a real life saver.

提交回复
热议问题