Do media queries within CSS stylesheets slow down page load times?
-
I know that having extra <link> elements with their own media queries causes extra HTTP requests. Is the same true for media queries written inline in the CSS document? Do they affect performance in any other ways?
-
Answer:
No, @import CSS methods slow down page load times (because they aren't parsed until the stylesheet is parsed) but media queries don't cause extra HTTP requests. As with other CSS selectors, you're not going to see an appreciable impact on performance until you're dealing with a massive site. Feel free to download a performance analyzer and see for yourself, but stylesheet parsing is rarely the number one concern for improving speed (you're better off optimizing images, implementing a spritesheet, minifying your assets, refactoring your Javascript ... you get the idea).
Cameron Daigle at Quora Visit the source
Other answers
There are two types of media queries possible inside a CSS document. If you just add media specific styles in a CSS stylesheet that can't lead to any extra HTTP request. The other is @import "smallscreen.css" only screen ; which is no different from extra link elements. I guess you might be referring to 'media' queries like background:url("/bg.gif"); which also creates a new request. In fact, if you write a media query for another file inside a CSS sheet that shall take more time because in that case the required objects are downloaded only after the CSS loads completely. While if you load the elements from a link tag or a preloader, the objects can be fetched parallel to the stylesheet resulting in lesser load time.
Vibhav Sinha
Related Q & A:
- How to prevent the white 'flash' on page load?Best solution by Stack Overflow
- How to call button click event in another page's load event?Best solution by codeproject.com
- Is there any way of seeing how many times a Wikipedia page has been viewed?Best solution by Yahoo! Answers
- Why won't My Yahoo home page load?Best solution by answers.yahoo.com
- How do I make a background image full page with CSS?Best solution by stradegyadvertising.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.