Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does importing same CSS file multiple times add any performance issues?

I have seen people discussing the same Javascript getting loaded multiple times, creating problems as the code runs every time on every include.

I am including the same CSS file multiple times in the same DOM (cannot avoid adding this as I'm using some components):

    <link href="style.css" rel="stylesheet" type="text/css">
  1. Will the DOM size increase?
  2. Does the CSS file get rendered every time on every include?
  3. Will this affect the performance of the page?

Note: As I am using the same CSS File, it is downloading only once.

like image 489
suppa.s Avatar asked Nov 14 '22 03:11

suppa.s


1 Answers

If your CSS file once rendered and used, second import of CSS won't be used and I don't think that it causes any problems. For example:

import css 1
import css 2

then you have here <p class="test"> and this test is only taken once for this tag from the css 1 import and the import css 2 will only be imported and not used. In this sense, I would say, this is only overhead and eats small amount of time for loading the file. I don't see further problems here.

like image 95
doniyor Avatar answered Dec 23 '22 06:12

doniyor