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

link prefetch new feature #26

Merged
merged 28 commits into from
Dec 14, 2024

Conversation

geckod22
Copy link
Contributor

Proposed changes

The changes are to add a new feature to the module called Link Prefetch. This make the admin able to set if and how the links should be prefetched to provide a faster navigation among the pages.
https://jira.newfold.com/browse/PRESS7-64

Type of Change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Video

Checklist

  • I have read the CONTRIBUTING doc
  • I have viewed my change in a web-browser
  • Linting and tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

imagen imagen

Depending on the selected options, the frontend js will manage the behaviour of this feature as explained in the options description texts. It will add a link rel=prefetch tag in the page header.

imagen

On Desktop:

  1. Prefetch on Mouse Hover (Recommended): the js will add the link tag after 60ms of the mouse hover so the broswer will prefetch and the link and when the actual redirection happen the loading will be faster.
  2. Prefetch on Mouse down: normally the click on a link really happens when the mouse button is released, and not when the button is pressed as one could imagine. So with this option we start to prefetch the link as soon as the mouse button is pressed.

On Mobile:

  1. Prefetch on Touchstart (Recommended): it is like the Mouse down option for desktop.
  2. Prefetch Above the Fold: in this case the js will prefetch all the links in the current view

@chrisdavidmiles
Copy link

Awaiting code review from @arunshenoy99

Copy link
Member

@arunshenoy99 arunshenoy99 left a comment

Choose a reason for hiding this comment

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

Hey @geckod22, thank you for the PR! Great work, especially since this is your first time working on this codebase. I’ve added a few minor comments and suggestions for optimisations. Please check and let me know if they make sense.

Also:

  • Let’s make sure to run the wp-scripts linter on the JS files.
  • Let’s add a newline at the end of each file to maintain consistency.

includes/LinkPrefetch.php Outdated Show resolved Hide resolved
includes/RestApi/LinkPrefetchController.php Outdated Show resolved Hide resolved
includes/RestApi/LinkPrefetchController.php Outdated Show resolved Hide resolved
includes/Performance.php Outdated Show resolved Hide resolved
includes/RestApi/LinkPrefetchController.php Outdated Show resolved Hide resolved
components/linkPrefetch/index.js Outdated Show resolved Hide resolved
components/linkPrefetch/index.js Outdated Show resolved Hide resolved
components/linkPrefetch/index.js Outdated Show resolved Hide resolved
components/performance/defaultText.js Outdated Show resolved Hide resolved
components/performance/defaultText.js Outdated Show resolved Hide resolved
arunshenoy99
arunshenoy99 previously approved these changes Nov 20, 2024
Copy link
Member

@arunshenoy99 arunshenoy99 left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks a lot @geckod22

@arunshenoy99 arunshenoy99 changed the base branch from main to release/v2.1.0 December 14, 2024 12:57
@arunshenoy99 arunshenoy99 merged commit e8537e7 into release/v2.1.0 Dec 14, 2024
1 check failed
@arunshenoy99 arunshenoy99 deleted the enhance/PRESS7-64-link-prefetch branch December 14, 2024 13:08
@arunshenoy99 arunshenoy99 mentioned this pull request Dec 14, 2024
14 tasks
@arunshenoy99 arunshenoy99 restored the enhance/PRESS7-64-link-prefetch branch December 16, 2024 09:09
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.

3 participants