Browser will try to load each stylesheet, of course if it has already been loaded and cached then it won't be downloaded again (but it will parse it).
I assume you don't want to put it in your master page because you have several components and each one has its own stylesheet (then you don't want to download all of them when using just few components).
Performance impact should be pretty small (both in parsing and applying same stylesheet again) but if you do one of these:
- You do patch CSS classes in multiple stylesheets (because patches by other CSSes will be overwritten);
- You do some trickery with your stylesheets (for example
$("#linkId").attr("href", "/example.com/override.css");
);
- You change them programmatially;
- You're relying on client side LESS parsing (with
type="text/less"
).
Then you may want to avoid a replacement (see also jQuery: add dom element if it does not exist):
<script type="text/javascript">
if ($("link[href='/example.com/component.css']").length == 0)
$("<link href='/example.com/component.css' rel='stylesheet'/>").appendTo("head");
</script>
In alternative you may use id
(instead of check with href
). Note that if you do it often then you may write an helper function.