Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Would a browser load a css file multiple times on the same page?

Tags:

html

css

I'm working on a large project in asp.net. I like breaking it apart by user controls so I was wondering if it would be OK to load the css in the user control code instead of in master page header?

Chances are, some of those controls would be represented multiple times on a single page so there would be duplicate style tags, would the browsers reload them or just ignore in that case?

like image 921
user81993 Avatar asked Sep 18 '15 08:09

user81993


1 Answers

the browser will load twice the css file, but in the second time it will probably cached, so it will be much faster.

the issue is, loading the file is not the only overhead here, because the browser will also need to re parse the css file, and re iterate the DOM tree, to check if any of the nodes in it match the new selectors, and then to apply them.

you are probobly better of including the css file once, and you should also look into css bundling, and minification.

like image 76
MoLow Avatar answered Oct 25 '22 05:10

MoLow