3

Why do Website Checkers Give CSS !important a Negative Score?

When building a performance driven website that is quick to render, it is often recommended to remove any CSS !important.

However, I've read that it doesn't affect performance - See is-important-bad-for-performance.

Based on that, if correct, there must be another reason for !important receiving negative scores, but what could it be, or do website checkers use outdated algorithms?

Note: This is not an SEO question. It is a website performance question.

j08691
  • 204,283
  • 31
  • 260
  • 272
  • 2
    Because important is never needed. It's a lazy solution which can cause more global classes to be overridden. – BRO_THOM Aug 20 '18 at 14:09
  • 1
    I am sometimes forced to use them when adding custom CSS to a WordPress theme or plugin. So there is a good use case for them. But is there a performance issue or something else that can negatively affect a site? –  Aug 20 '18 at 14:12
  • *"I am sometimes forced to use them when adding custom CSS"* Then you are doing it wrong. Proper specificity will be more than adequate as would a proper WP theme fork. – Paulie_D Aug 20 '18 at 14:18
  • 1
    Website checkers are opinionated - perhaps their definition of performance includes the maintenance cost of dealing with excessive use of !important, therefore all use of !important is negative. – chazsolo Aug 20 '18 at 14:27
  • 1
    I think, this is answering your question: https://stackoverflow.com/questions/8360190/is-it-bad-to-use-important-in-css-property – Othmane Aug 20 '18 at 14:28

1 Answers1

2

If you rely on the !important property, the CSS file of yours will get bigger and bigger with every edit. That is not a good way to do work. If you have time please do not use !important. It is not meant to use on a regular basis. The program they use to determine the speed of website is setted to gate !important as an extra property is not recommended. So if you do not require !important, do not use it. If it is an temporary work use it as it is not a big deal.

Eb946207
  • 748
  • 8
  • 26
mourshad
  • 21
  • 2