Does the same CSS file affect any performance issues several times?

I saw people discussing the same Javascript that loaded several times, creating problems, because the code runs every time every time it is turned on.

I include the same CSS file several times in the same DOM (I cannot avoid adding this, as I use some components):

<link href="style.css" rel="stylesheet" type="text/css"> 
  • Will the DOM size increase?
  • Does the CSS file appear every time I turn it on?
  • Will this affect page performance?

Note. Since I use the same CSS file, it only loads once.

+4
source share
2 answers

I would think that this would add extra overhead, because although the stylesheet is cached in your browser, it still needs to check if it is cached for multiple inclusions (unless your browser combines all the unique stylesheets before receiving them). Even so, I expect latency to be minimal, but certainly will not improve performance. If you split the stylesheet into several files, you can get a tangible performance boost during the initial loading due to simultaneous HTTP connections, but the cost of maintaining this separation software is unlikely to be worth it, and it won’t do anything for you on subsequent page loads .

0
source

If your CSS file was once rendered and used, the second CSS import will not be used, and I don't think it causes any problems. For instance:

 import css 1 import css 2 

then you are here <p class="test"> , and this test taken only once for this tag from the css 1 import, and the css 2 import will be imported and will not be used. In this sense, I would say this is only an overhead charge and eats a small amount of time to download a file. I do not see further problems here.

0
source

All Articles