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

Reduce application.css file size #4944

Merged
merged 2 commits into from
Jan 24, 2025

Conversation

coalest
Copy link
Collaborator

@coalest coalest commented Jan 23, 2025

Description

I noticed our main CSS file is quite large (> 3 mb). Reducing it should improve browser performance.

This PR presents two changes:

  1. Fix AdminLTE CSS duplication. We were accidentally bundling all the AdminLTE CSS twice, since we had @import 'AdminLTE' repeated in two files. From the documentation:

⚠️ Heads up!

If the same stylesheet is imported more than once, it will be evaluated again each time. If it just defines functions and mixins, this usually isn’t a big deal, but if it contains style rules they’ll be compiled to CSS more than once.

  1. Replace the regular AdminLTE CSS file (version 3.2.0) to the version bundled without the dark-mode related CSS since we aren't using dark mode as far as I can tell. (We can always add it back if we want to implement dark mode in the future.)

Type of change

  • Internal

How Has This Been Tested?

I did some side-by-side comparison with staging after the changes and everything looks the same to me. 🤷

Screenshots

Reduces the file size by about 2 megabytes in raw file size (160 kb over the wire).
Before:
Screenshot from 2025-01-23 15-27-35
After:
image

@coalest coalest changed the title Reduce application.css file size by removing dark-mode css from AdminLTE Reduce application.css file size Jan 23, 2025
@import 'bootstrap';
@import 'AdminLTE';
Copy link
Collaborator Author

@coalest coalest Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are removing the second AdminLTE import (from custom.scss), we have to move this import after the bootstrap import. Because AdminLTE depends on and includes bootstrap 4.6 inside it's css, and we want bootstrap 4.6 to have priority over the other bootstrap (version 5.2).

@@ -53,15 +52,6 @@
}
}

.wrapper-form-feedback {
@extend .dropdown-item;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This @extend call required the adminLTE import, but looks like we aren't using this wrapper-form-feedback class anywhere so I went ahead and removed it.

Copy link
Collaborator

@dorner dorner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK on my end.

@dorner dorner requested a review from cielf January 24, 2025 01:48
@cielf
Copy link
Collaborator

cielf commented Jan 24, 2025

I didn't check absolutely everything, but enough breadth and depth that I'm confident in this.

@cielf cielf merged commit 7ce6e5d into rubyforgood:main Jan 24, 2025
11 checks passed
@coalest coalest deleted the reduce-application-css-filesize branch January 26, 2025 14:00
Copy link
Contributor

@coalest: Your PR Reduce application.css file size is part of today's Human Essentials production release: 2025.01.26.
Thank you very much for your contribution!

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.

3 participants