Using an external css grid-work is beneficial but the load times are intense especially with the breakpoint media queries. What are the pros and cons to loading multiple stylesheets, 1 main one with general grid-layout css, and then other stylesheets to accommodate for the media query breakpoints for that css grid layout?
If this is a good idea then this could be the next new standard for optimized css loading.
Multiple Media Query Stylesheets
Examples:
Here is an normal example grid layout stylesheet
Pros: works great and reliable, all css in one location
Cons: has a very large file size, cluttered by massive media query blocks
<link href="style.css" rel="stylesheet">
.col-md-6 {
width: 50%;
}
@media all and (max-width: 768px) {
.col-md-6 {
width: 100%;
}
}
Here is an example of multiple stylesheets based on media queries
Pros: sectionalizes code out, declutters, may reduce load times per Google's documentation
Cons: not sure what they are honestly, perhaps browser support, but that's what I need help figuring out
<link href="style.css" rel="stylesheet">
.col-md-6 {
width: 100%;
}
<link href="style-768.css" rel="stylesheet" media="all and (max-width: 768px)">
.col-md-6 {
width: 100%;
}
From what i can tell here on Googles Developer docs a stylesheet that is only loaded when needed (i.e. at max-width: 768px) is only seen as 'render-blocking' if it is used. When it is not used then this whole stylesheet can possibly be skipped over and dramatically reduce the initial load of the css needed at that time.
Is this a good practice? seems like cutting out 2/3s of a css grid system by relocating media query blocks has serious benefits, but perhaps that is canceled out by the DOM needing to get more than one CSS doc?