Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defer non-critical CSS without changing cascade order #1448

Merged
merged 1 commit into from
Nov 20, 2024
Merged

Conversation

thatbudakguy
Copy link
Member

With 9254fbf, we deferred non-critical CSS by loading it at the
end of the page. However, this had an unintended side-effect:
making the viewer CSS load last in the cascade.

This meant that fixes like geoblacklight/geoblacklight@12bd71f
had no effect, because they were loaded as part of geoblacklight's
CSS and then overridden by the viewer's own CSS.

This change switches to the strategy outlined in
https://web.dev/articles/defer-non-critical-css,
which defers CSS loading but reverts to the original DOM order
for the styles, preserving the ability to affect Leaflet's
styles in our own without resorting to !important.

It also removes one instance where we were using !important
to get around this problem.

With 9254fbf, we deferred non-critical CSS by loading it at the
end of the page. However, this had an unintended side-effect:
making the viewer CSS load last in the cascade.

This meant that fixes like geoblacklight/geoblacklight@12bd71f
had no effect, because they were loaded as part of geoblacklight's
CSS and then overridden by the viewer's own CSS.

This change switches to the strategy outlined in
https://web.dev/articles/defer-non-critical-css,
which defers CSS loading but reverts to the original DOM order
for the styles, preserving the ability to affect Leaflet's
styles in our own without resorting to !important.

It also removes one instance where we were using !important
to get around this problem.
@hudajkhan hudajkhan merged commit 9ac384f into main Nov 20, 2024
2 checks passed
@hudajkhan hudajkhan deleted the css-defer branch November 20, 2024 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants