jquery: speed difference between .css vs append to head?

后端 未结 3 1595
再見小時候
再見小時候 2021-01-26 22:18

We have some kludgy workarounds for an internal app and I was wondering which jQuery/css technique is considered faster / more efficient ...etc.

Technique A

3条回答
  •  春和景丽
    2021-01-26 23:05

    jQuery's .css is faster than appending to head with the sample you provided. I have created a test case which demonstrates this here: http://jsperf.com/jquery-css-vs-append-to-head

    enter image description here

    As far as offsite CSS, its not comparable, because offsite css speed is dependent on the users internet connection, along with your server speed ect. If you have a wicked server and broadband users, I say offsite is much better, otherwise for speed you can only reliably count on javascript.

提交回复
热议问题