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

Prerender EAGERNERSS #436

Merged

Conversation

giorgiopellegrino
Copy link
Contributor

@giorgiopellegrino giorgiopellegrino commented Dec 5, 2024

Hello @addyosmani and @XhmikosR,

I have implemented a key feature for my company that allows prerendering URLs with an eagerness configuration. The fallback is a prefetch triggered on mouseenter when the eagerness property is set to "moderate" or "conservative."

Main changes:

  1. Added functionality to prefetch elements corresponding to the URL upon the mouseenter event.
  2. Added the handling of the eagerness attribute of the script in the speculation rules.
  3. The prerender fallback for devices that do not handle speculation rules has been implemented by adding prefetch, triggered at the mouseenter, if the eagerness mode is ‘moderate’ or ‘conservative’.
  4. All the functions added for prefetch and prerender are available in the listen function to options property, and they will only be executed when elements enter the viewport: options.onlyOnMouseover, options.eagerness
window.addEventListener('load', () => {
  quicklink.listen({el, priority, onlyOnMouseover,
                    prerender, eagerness});
});
quicklink.prefetch(url, isPriority, onlyOnMouseover);
quicklink.prerender(url | [urls], eagerness);

I hope these changes will be appreciated, as they are currently in use across our e-commerce platforms.

Thank you very much.

Giorgio Pellegrino.

cc @gilbertococchi

@giorgiopellegrino giorgiopellegrino changed the title Prerender eagerness Prerender EAGERNERSS Dec 5, 2024
Copy link
Collaborator

@addyosmani addyosmani left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the contribution!

@addyosmani
Copy link
Collaborator

@giorgiopellegrino could i ask if you can resolve the conflicts introduced after we landed #435? Happy to land this after.

@giorgiopellegrino
Copy link
Contributor Author

Hello @addyosmani ,

I’ve pulled the latest changes from the main branch and solved the conflicts.

Thank you for merging the pull requests!

Giorgio

cc @gilbertococchi

@addyosmani
Copy link
Collaborator

Thank you for resolving those merge conflicts. Very much appreciate it.

Copy link
Collaborator

@addyosmani addyosmani left a comment

Choose a reason for hiding this comment

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

LGTM

@addyosmani addyosmani merged commit 187184f into GoogleChromeLabs:main Mar 22, 2025
9 of 11 checks passed
@giorgiopellegrino
Copy link
Contributor Author

Hi @addyosmani , thank you so much for completing the pull request!
cc @gilbertococchi

@addyosmani
Copy link
Collaborator

Thank you so much once again for all of your work on the recent pull requests. I really appreciate the improvements that you've been making to the library. I will aim to get these out in a new release soon. We're just going to try cleaning up some final additions that ideally get our CI passing again, but expect them to be in a stable release soon.

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.

2 participants