Media queries or multiple sheets of styles?

Asked

Viewed 113 times

0

In a matter of making the site fast and responsive, which is best?

1-Use Media Queries and set resolutions in one style sheet only.

2-Use various style sheets that will be called in HTML according to resolution.

  • I’m not sure about the performance, but you can test the load in both ways and see if it makes a difference. In my opinion without a doubt use Media Queries, besides being more elegant maintenance can be simpler, because in a file are the styles, instead of having several files.

  • You can develop in separate files and use an automation tool to include everything in a single file.

  • Currently, it is very rare to find sites with media queries in separate files. Generally all code is found in only one CSS file.

1 answer

0

It is recommended to use only one style sheet file (.css). Below is a list of pros and cons. Remembering that are only recommendations and observations... any of the methods is effective.

Pros of a. css file:

  • 1 HTTP request;
  • Easiest you don’t forget to update some specific Media Querie.

Cons of a. css file:

  • File size is larger;
  • The bigger the project, the harder the maintenance;
  • Required Javascript solutions to work on IE8 down.

Pros of using multiple files:

  • Default file is smaller;
  • Facilitates maintenance and organization.

Against using multiple files:

  • Several HTTP requests;
  • Worsens maintenance compared to forgetting to update an item in a particular file.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.