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

Use <LoadingFrame> component to reduce content layout shift (CLS) #463

Open
glenbraun opened this issue Nov 30, 2020 · 3 comments · May be fixed by #1072
Open

Use <LoadingFrame> component to reduce content layout shift (CLS) #463

glenbraun opened this issue Nov 30, 2020 · 3 comments · May be fixed by #1072
Assignees
Labels
Front End Primarily front-end (react/javascript) javascript Pull requests that update Javascript code Performance

Comments

@glenbraun
Copy link
Collaborator

glenbraun commented Nov 30, 2020

Google is flagging us for a low CLS score

https://web.dev/cls/

https://trello.com/c/IykqFcaE

@glenbraun glenbraun added the Investigation Issue has been raised but needs further detail to form a solution label Dec 2, 2020
@PeterBreen
Copy link
Collaborator

PeterBreen commented Apr 26, 2021

#573 includes some changes which result in a huge improvement to CLS - project and group pages now have CLS values reduced by just over 90% by using <LoadingFrame /> to ensure less visible content shift while waiting for backend data to return. For any other pages which match this pattern, use of LoadingFrame should improve CLS there also. Testing of different height values to get the best return on CLS is also needed; I just picked a value which worked but isn't optimized for the purpose.

@PeterBreen PeterBreen added javascript Pull requests that update Javascript code Front End Primarily front-end (react/javascript) Performance labels Jun 2, 2022
@PeterBreen
Copy link
Collaborator

PeterBreen commented Jun 2, 2022

To close this item specifically I think we need to audit all our pages for CLS. The homepage does quite well; Lighthouse gives me 0.029, but Find Projects gives 0.26 and Find Groups gives 0.319 -- not great for either of those.

So,

  • audit all pages for CLS (browser devtools Lighthouse reporting is sufficient)
  • use <LoadingFrame /> on pages which don't currently have it to help reduce CLS
  • further changes as needed, but it's likely that's enough given the results from Group profile page update #573 as mentioned previously.

@PeterBreen
Copy link
Collaborator

PeterBreen commented May 15, 2023

An example of how to use LoadingFrame for a page where the whole page content needs to wait for API return: https://github.com/DemocracyLab/CivicTechExchange/blob/506de6a6c74b04de7dbe1925ffe89d427171907a/common/components/controllers/AboutProjectController.jsx#L91C6-L95

not all pages can return error codes, but for ones that do follow this pattern. Show either a load or error message if API request data hasn't been returned yet, render the page when it has.

And for an individual component which has to wait:
https://github.com/DemocracyLab/CivicTechExchange/blob/506de6a6c74b04de7dbe1925ffe89d427171907a/common/components/common/carousel/BlogCarousel.jsx (see Line 34-55)

I think almost all uses will be the first example (page content level) rather than component, but both are viable.

Any further SEO or CLS fixes can go in another branch. Let's just reuse our existing components for now.

@PeterBreen PeterBreen removed the Investigation Issue has been raised but needs further detail to form a solution label May 15, 2023
@PeterBreen PeterBreen changed the title SEO: Investigate Improving CLS Use <LoadingFrame> component to reduce content layout shift (CLS) May 15, 2023
@QuanGiap QuanGiap assigned QuanGiap and unassigned QuanGiap Aug 26, 2023
@caveman0612 caveman0612 self-assigned this Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Front End Primarily front-end (react/javascript) javascript Pull requests that update Javascript code Performance
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants