Closed querkmachine closed 1 year ago
I think there are a couple of things that are going on in our codebase that are worth pointing out as they are somewhat hidden / confusing:
Rules are repeated in several places where media queries have been removed. postcss-unmq should be removing the duplicates and only including the rules relevant to the configured screen dimensions (by default, 1024×768)—however this doesn't appear to be happening.
We're using a vendored version of sass-mq under the hood – wherever you see the govuk-media-query
mixin being used, under the hood that's calling sass-mq:
One of the features of sass-mq is that it 'rasterizes' media queries – so wherever govuk-media-query
is used and the media query matches our desktop breakpoint, it'll be outputted without being wrapped in a media query:
There's nothing intelligent going on to remove duplicates and – because this happens as part of the Sass compilation step – there's no media query left for unmq
to do anything with.
We do have a few other places in the codebase where we use @media
rules directly instead of calling govuk-media-query
(not for breakpoints – typically used for things like @media (forced-colors: active)
or @media (hover: none)
. Because these don't go through the mixin, they are included in the CSS and this is where unmq
does help as it removes them for us.
The presence of both rem and px unit versions is due to node-pixrem. Having the rem unit versions is unnecessary in the IE8 stylesheet, too.
.govuk-\!-font-size-19 { font-size: 16px!important; font-size: 1rem!important; line-height: 1.25!important; font-size: 19px!important; font-size: 1.1875rem!important; line-height: 1.31579!important; }
To the best of my knowledge, we've never used node-pixrem
for this. Our typography scale is defined in px, and our typography helpers convert them to rem and output both font-size declarations:
There's a flag to enable this ($govuk-typography-use-rem
). If we wanted to, we could update the govuk-typography-responsive
mixin to consider both flags (@if $govuk-typography-use-rem and not $govuk-is-ie8 {
) or consider $govuk-is-ie8
when setting the default value for $govuk-typography-use-rem
.
Closing as we're now starting work on GOV.UK Frontend 5, which drops support for IE8.
Cause
Unnecessary CSS, such as repeated style rules and features that are not supported by Internet Explorer 8, is still being included in the IE8-specific stylesheet, despite efforts to automatically remove these features.
Noticed during the 4.5.0 release process.
Repeated rules
Rules are repeated in several places where media queries have been removed. postcss-unmq should be removing the duplicates and only including the rules relevant to the configured screen dimensions (by default, 1024×768)—however this doesn't appear to be happening.
The presence of both rem and px unit versions is due to node-pixrem. Having the rem unit versions is unnecessary in the IE8 stylesheet, too.
Unsupported rules
Unsupported CSS rules are still included, such as the flexbox-related rules here.
And
box-shadow
andbox-decoration-break
rules here:Unsupported selectors
Selectors incorporating the
:not
selector are included in the stylesheet, despite not being supported by IE8.Same for
:last-child
and:last-of-type
here.Unsupported functions
Several CSS functions not supported by IE8 are still included. In this example, none of
calc()
,env()
ormax()
are supported in IE8.Third-party browser prefixes
Some browser-prefixed properties and values are still included, despite not being relevant to IE8.
@supports
at-rule@supports
at-rules are included in the stylesheet, despite IE8 not supporting them.Consequences
We ship significantly more CSS to IE8 than the browser is capable of using. This may have an exacerbated effect on performance as any contemporary IE8 users are probably running very old hardware and software.
Impact of debt
Low
Reason
Considered as low because:
Effort to pay down
High
Reason
Some of these issues could be resolved manually by wrapping the offending code in the
govuk-not-ie8
mixin, so that it's not included in the IE8 stylesheet.For others: We currently use the Oldie plugin to automatically remove unsupported features in the IE8 stylesheet. Oldie appears to be unmaintained, with issues and pull requests not being monitored. We would likely have to fork the plugin or its dependencies if we wanted to make updates to how it works.
Despite us planning to drop support for IE8 going forward, we will still be supporting it on a security and major bugfix basis for at least a year following the release of Frontend v5. We may want to pay down some of this debt so that things are in a better place before we reduce and drop IE8 support completely.
Overall rating
Low