Why won't my @media queries work?

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

Was this solution helpful to you?

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:

Just Added Q & A:

Find solution

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.