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 Layout shifts, Inline Styling - Set fixed height/width where possible #2075

Merged
merged 1 commit into from
Jan 28, 2021

Conversation

arslanashraf7
Copy link
Contributor

@arslanashraf7 arslanashraf7 commented Jan 20, 2021

Pre-Flight checklist

  • Testing
    • Code is tested
    • Changes have been manually tested

What are the relevant tickets?

Related to #2065

What's this PR do?

Attempts to optimize the Catalog & Product Pages through suggestions provided by Lighthouse

  • Sets fixed styling(height/width) for the elements where possible to avoid layout shifts.
  • Adds lazy loading to the images where possible.
  • Defers a Zendesk script

How should this be manually tested?

Open any of the Catalog/Product and check the statistics on LightHouse, Make sure that the page loads in a better amount of time than before. Make sure that we caught maximum possible suggestions through Lighthouse regarding images layout shifts, setting height/width of images.

@odlbot odlbot temporarily deployed to xpro-ci-pr-2075 January 20, 2021 14:13 Inactive
@arslanashraf7 arslanashraf7 force-pushed the arslan/2068-performance-product branch from db1cc07 to 36be99c Compare January 20, 2021 17:17
@odlbot odlbot temporarily deployed to xpro-ci-pr-2075 January 20, 2021 17:18 Inactive
@arslanashraf7 arslanashraf7 force-pushed the arslan/2068-performance-product branch from 36be99c to cfca481 Compare January 20, 2021 19:43
@codecov-io
Copy link

codecov-io commented Jan 20, 2021

Codecov Report

Merging #2075 (10436f2) into master (d5ac020) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2075      +/-   ##
==========================================
- Coverage   88.00%   87.99%   -0.02%     
==========================================
  Files         328      328              
  Lines       14767    14767              
  Branches     1031     1031              
==========================================
- Hits        12996    12994       -2     
- Misses       1532     1534       +2     
  Partials      239      239              
Impacted Files Coverage Δ
static/js/components/TopAppBar.js 100.00% <ø> (ø)
static/js/components/UserMenu.js 100.00% <ø> (ø)
static/js/containers/pages/ReceiptPage.js 100.00% <ø> (ø)
cms/models.py 91.18% <100.00%> (ø)
static/js/components/forms/BulkEnrollmentForm.js 90.62% <0.00%> (-1.57%) ⬇️
...tic/js/components/forms/BulkEnrollmentForm_test.js 98.73% <0.00%> (-1.27%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d5ac020...10436f2. Read the comment docs.

@odlbot odlbot temporarily deployed to xpro-ci-pr-2075 January 20, 2021 19:43 Inactive
@arslanashraf7 arslanashraf7 changed the title Arslan/2068 performance product Performance Improvement | Product Page Jan 20, 2021
@arslanashraf7 arslanashraf7 force-pushed the arslan/2068-performance-product branch from cfca481 to 97805cf Compare January 21, 2021 11:21
@odlbot odlbot temporarily deployed to xpro-ci-pr-2075 January 21, 2021 11:21 Inactive
@arslanashraf7 arslanashraf7 force-pushed the arslan/2068-performance-product branch from 97805cf to aaf88f9 Compare January 21, 2021 12:17
@odlbot odlbot temporarily deployed to xpro-ci-pr-2075 January 21, 2021 12:17 Inactive
@arslanashraf7 arslanashraf7 changed the title Performance Improvement | Product Page Performance Improvement | Product Page, Catalog Page Jan 21, 2021
) or CoursePage.objects.filter(
featured=True, course__live=True
)
featured_product = program_page_qset.filter(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change just reuses the queryset that we created above for Program and Course Pages, Plus we were not checking for .live() while obtaining the Featured Product.

@odlbot odlbot temporarily deployed to xpro-ci-pr-2075 January 22, 2021 10:56 Inactive
@gsidebo
Copy link
Contributor

gsidebo commented Jan 22, 2021

I'd recommend getting rid of the other PR that this is rebased on, and just keeping this PR. It's not necessarily in our interests to break these performance PRs up by CMS page. The performance improvements in general are strongly linked to each other, and there are limited examples of improvements that are only relevant to these specific pages.

Copy link
Contributor

@gsidebo gsidebo left a comment

Choose a reason for hiding this comment

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

@arslanashraf7 Could you split this into 2 pull requests? (1) should contain the lazy div loading code. (2) should contain everything else. I'm concerned that that lazy div loading opens us up to weird/buggy behavior for questionable performance gains. We can set that lazy div loading PR to "On Hold", and we can review/merge it if it seems like our other less-risky changes are not having the desired effect

@arslanashraf7
Copy link
Contributor Author

arslanashraf7 commented Jan 27, 2021

@gsidebo I Totally agree with you, I was also very much inclined towards the division of this PR. I'll divide this PR into two and also check if there are more elements in general where we could improve layout shifts.

As for division, I'll keep all the Non lazy div loading changes in this PR(Will update the title), and move out all the lazy div related changes into a new one with Hold label.

@odlbot odlbot temporarily deployed to xpro-ci-pr-2075 January 27, 2021 08:05 Inactive
@arslanashraf7 arslanashraf7 force-pushed the arslan/2068-performance-product branch from 5b70053 to 5c18d79 Compare January 27, 2021 08:10
@odlbot odlbot temporarily deployed to xpro-ci-pr-2075 January 27, 2021 08:10 Inactive
@arslanashraf7 arslanashraf7 changed the title Performance Improvement | Product Page, Catalog Page Reduce Layout shifts, Inline Styling - Set fixed height/width where possible Jan 27, 2021
@arslanashraf7 arslanashraf7 force-pushed the arslan/2068-performance-product branch from 5c18d79 to 2345671 Compare January 27, 2021 08:21
@odlbot odlbot temporarily deployed to xpro-ci-pr-2075 January 27, 2021 08:21 Inactive
@arslanashraf7 arslanashraf7 force-pushed the arslan/2068-performance-product branch from 2345671 to 69397bc Compare January 27, 2021 08:31
@arslanashraf7 arslanashraf7 changed the base branch from 2065-performance-improvements to master January 27, 2021 08:32
@odlbot odlbot temporarily deployed to xpro-ci-pr-2075 January 27, 2021 08:32 Inactive
@arslanashraf7
Copy link
Contributor Author

@gsidebo I've divided this PR as per above mentioned comment, All the lazy load div related changes have been moved to #2090.

Copy link
Contributor

@gsidebo gsidebo left a comment

Choose a reason for hiding this comment

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

Pages load as expected. Ship it! 👍

Copy link
Contributor

@gsidebo gsidebo left a comment

Choose a reason for hiding this comment

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

(Sorry, let's try that again...) Pages load as expected. Ship it! 👍

@gsidebo gsidebo self-assigned this Jan 27, 2021
@arslanashraf7 arslanashraf7 merged commit 82d57b0 into master Jan 28, 2021
@arslanashraf7 arslanashraf7 deleted the arslan/2068-performance-product branch January 28, 2021 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants