This repository has been archived by the owner on Jan 11, 2022. It is now read-only.
Render sticky elements on document.readyState === 'interactive' #40
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi @rgalus ,
I am using this library for a production site (thank you for the library—it's great!) and ran into an issue that stems from that site's heavy use of DFP ads. I understand why the library waits for
document.readyState === 'complete'
before rendering the sticky elements—to ensure that all cached element positions are accurate as asynchronously rendering elements (images in particular) may affect the height of the page—but it also results in long delays before the stickiness kicks in when certain assets (cough ads) take a long time to execute. This is of course a problem with the site itself rather than the library, but I think the library's handling of this imperfect situation could be improved.The solution that we tested and which is working for us is to fire the initial render on
document.readyState === 'interactive'
, which triggers the stickiness on relevant elements as soon as the user can scroll/interact with the page, even if certain assets delay the page load. Then, when the document completes, trigger anupdate()
to recalculate positions in order to account for possible changes in document height.Please let me know if you have any questions about this.