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

[Performance] CSS Loading improvements #3564

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

adearriba
Copy link

@adearriba adearriba commented Jul 13, 2024

PR Summary:

Why are these changes introduced?

  1. Dawn loads many CSS files that it doesn't use depending on certain configuration.
  2. Footer CSS is blocking and normally the footer is not immediately seen so it can be deferred to onload.

Edit: Additional perf improvements not related to CSS:

  1. Reduce event listeners for "summary" and "location-form" elements.

What approach did you take?

Conditional CSS loading. Only load the CSS files when needed based on liquid variables that enable or disable certain functionality.

Other considerations

Decision log

# Decision Alternatives Rationale Downsides
1 Load CSS when needed Current state: Load everything, every time Only load when needed To improve performance, the CSS should be created by component and sometimes separated by feature. This will enable to load only the required CSS instead. Of course this must be done with balance based on CSS size.
2 Reduce event listeners Current state: querySelectorAll and apply event listeners per element Use event delegation to reduce memory footprint None

Visual impact on existing themes

Since the decision to load CSS is based on the settings, it should affect anyone.

Testing steps/scenarios

  • Enable/Disable product ratings and check product-ratings component
  • Test facets swatches and show-more components
  • Test Announcement bar with more than 1 block
  • Test Product quick add and volume pricing

Checklist

@adearriba
Copy link
Author

I have signed the CLA!

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.

1 participant