jQuery - is it bad to have multiple $(document).ready(function() {});

后端 未结 5 817
孤街浪徒
孤街浪徒 2020-11-27 05:56

Is it bad to have multiple $(document).ready(function() {}); on your page? I have a website where I load different things at different times. I fire off those p

5条回答
  •  时光说笑
    2020-11-27 06:36

    If it's on the same page I would personally put them all in the same place so that you can't be caught out by forgetting one of the things happening on load.

    I doubt the performance implications are that significant though. Have you tried benchmarking the page with them all together and apart?

提交回复
热议问题