Skip to content

perf: optimize prefetching with network awareness and user toggle#156

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
Agbasimere:main
Apr 23, 2026
Merged

perf: optimize prefetching with network awareness and user toggle#156
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
Agbasimere:main

Conversation

@Agbasimere
Copy link
Copy Markdown
Contributor

Closes: #129

Overview

This PR addresses the overhead of the PrefetchingEngine by making it smarter and more bandwidth-efficient. Previously, the engine would prefetch resources on every hover regardless of network conditions or user preferences.

Changes

  • Network-Aware Checks: Integrated isSlowConnection checks that detect constrained connections (2G, 3G, or Save-Data mode) to disable prefetching automatically.
  • User Preference Toggle: Added a new "Enable Smart Prefetching" toggle in the Profile Settings under "Display Settings" / "Performance".
  • Optimized Strategy:
    • Introduced a 50ms delay on hover to ensure intent and avoid accidental prefetching during rapid mouse movement.
    • Added touchstart support for mobile devices to prefetch on initial touch.
    • Implemented a de-duplication mechanism to avoid redundant prefetch calls for the same URL.
  • Store Integration: Added the prefetching preference to the global state manager (Zustand) with persistence.

Impacted Files

  • src/store/stateManager.ts
  • src/components/profile/ProfileEditForm.tsx
  • src/components/profile/PreferencesSection.tsx
  • src/components/performance/PrefetchingEngine.tsx

Acceptance Criteria

  • Check network conditions before prefetching.
  • Support Save-Data preference.
  • User can toggle prefetching in settings.
  • Prefetching is optimized (delay + de-duplication).

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 23, 2026

@Agbasimere Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER
Copy link
Copy Markdown
Contributor

FIX CI

@RUKAYAT-CODER RUKAYAT-CODER merged commit d4d4326 into rinafcode:main Apr 23, 2026
2 of 6 checks passed
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.

Prefetching Overhead

2 participants