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

Added styles and render logic to reduce load jank #56

Merged
merged 5 commits into from
Jan 23, 2023

Conversation

iansvo
Copy link
Contributor

@iansvo iansvo commented Jul 11, 2022

Description of the Change

Closes #38

This adds some CSS to remove the element from the document flow (via absolute positioning) and using a timer that starts when the load event fires in the browser to then remove the absolute positioning.

The effect is that the element is inserted into the DOM after its dimensions are calculated, which prevents the scrolling.

Possible Drawbacks

The timeout value is at 1000ms, which is kind of arbitrary. There isn't a complete way to guarantee perfect loading as the widget could delay for any number of reasons unrelated to the webpage (such as network speed, device resources, and so on).

It is possible we might want to hook into this using some other mechanism (mutation change, perhaps?) but that rabbit hole can get deep really quickly and I think the solve should start simpler and move from there after we do some real world testing.

Verification Process

I started with replicating the issue locally on a barebones page that didn't have much on it besides the widget. I was able to replicate the issue with relative consistency when the page was not cached.

After the update I went through the same steps and found the issue was not able to be reproduced.

Note: This issue should be verified on a staging/production environment using a configured theme and a more realistic page setup to confirm the durability of the solution. Hopefully this is something triage in the related issue can resolve.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation. (I think this is FAQ material at least)
  • I have updated the documentation accordingly.
  • I have added tests to cover my change. (N/A)
  • All new and existing tests passed.

Changelog Entry

Added - Additional handling to prevent page jank and scrolling as the webamp widget loads

Credits

Props @iansvo

@iansvo iansvo mentioned this pull request Jul 11, 2022
1 task
@jeffpaul jeffpaul added this to the 1.1.1 milestone Jul 11, 2022
@jeffpaul jeffpaul requested review from a team and cadic and removed request for a team July 11, 2022 15:37
@iansvo
Copy link
Contributor Author

iansvo commented Jul 11, 2022

@jeffpaul I just noticed that the JS lint fails, it's saying there's a package missing which my changes didn't alter either. Possible version issue with the deps?

cadic
cadic previously approved these changes Aug 18, 2022
Copy link
Contributor

@cadic cadic left a comment

Choose a reason for hiding this comment

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

The code looks good, just a potential cleanup for node packages

@@ -1,7 +1,7 @@
import Webamp from 'webamp';
import domReady from '@wordpress/dom-ready';
Copy link
Contributor

Choose a reason for hiding this comment

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

@wordpress/dom-ready is no more a dependency for this and other scripts, could be removed from package.json

Copy link
Member

Choose a reason for hiding this comment

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

@iansvo if you concur with ^, mind a quick commit to pull that out?

Copy link
Member

Choose a reason for hiding this comment

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

@cadic could you handle that update and then look to get this merged in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cadic @jeffpaul Update is made confirmed build succeeds, merged in latest from dev and regenerated package-lock.json.

@jeffpaul
Copy link
Member

@iansvo mind helping resolve the merge conflicts and then @cadic can do final review/merge?

@jeffpaul
Copy link
Member

@10up/open-source-practice would be great to get some assistance resolving the merge conflicts here so that this can get into final review/merge... thanks!

# Conflicts:
#	package-lock.json
#	src/frontend.js
@peterwilsoncc
Copy link
Contributor

@10up/open-source-practice I've resolved the merge conflicts but am unable to reproduce the issue described so will need someone else to test and review.

Copy link
Member

@Sidsector9 Sidsector9 left a comment

Choose a reason for hiding this comment

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

Thanks for resolving the conflicts @peterwilsoncc

I was not able to reproduce this issue locally however I was able to on a live site.
I used instawp to test.

Issue on the develop branch:

Screen.Recording.2023-01-23.at.12.31.03.PM.mov

Issue resolved in the fix brach:

Screen.Recording.2023-01-23.at.12.37.56.PM.mov

I have tested on pages with and without content and it worked well for me.

@Sidsector9 Sidsector9 merged commit 5b56372 into develop Jan 23, 2023
@Sidsector9 Sidsector9 deleted the fix/issue-38-page-jump-on-load branch January 23, 2023 07:15
@Sidsector9 Sidsector9 mentioned this pull request Jan 24, 2023
1 task
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.

page loading at the bottom
5 participants