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

后端 未结 3 1592
再見小時候
再見小時候 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 22:50

    Offsite css is the way to go. with offsite css the browser only needs to make one request which is usually pretty fast.

    on the other hand whenever you modify css elements, the browser must reparse the entire dom tree which is probably more expensive.

    The other important question is:

    Is speed really as important here as you think it is? Maybe the difference is 45ms between these solutions, which is hardly anything you should care about. You should choose a technique which allows you to write code faster and maintain it better, thats where the real time savings will come in.

提交回复
热议问题