=== Project Studios Intent Prefetch ===
Contributors: shaunpalmer
Tags: prefetch, performance, speed, navigation, hover
Requires at least: 6.3
Requires PHP: 7.4
Tested up to: 7.1
Stable tag: 1.0.1
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Instant navigation: warms internal links on hover or tap, and never prerenders — so analytics stay honest.

== Description ==

Project Studios Intent Prefetch improves perceived WordPress navigation speed by warming the browser cache for same-origin internal links when the visitor shows intent to click them — hovering over a link, or tapping one on touch devices — without fetching the entire site up front.

= Why not prerender? =

The two most-downloaded plugins in this space **prerender**: they load the next page in a hidden tab, which runs its scripts. That fires your analytics for a visit the visitor never made — inflated pageviews, phantom conversions, and a session that never happened.

Project Studios Intent Prefetch only ever **warms the browser cache**. It never prerenders, never executes the fetched page's scripts, and never follows a redirect. The visit is counted when — and only if — the visitor actually arrives.

That is a tested property, not a slogan: the plugin's own tests assert that no prerender hint and no speculation rule is ever emitted.

= What it does not do =

* No prerendering, no hidden tabs, no speculation rules.
* No tracking, no telemetry, no external requests.
* No admin nags, no upsell, no "powered by" link on your site.
* No page-builder-specific code — it listens on the document and works with any theme.

Why this plugin is different:

* Tiny vanilla JavaScript. No jQuery, no external prefetch libraries, no build tooling.
* Same-origin only by default. External domains are never touched.
* Never executes the prefetched page. The response is streamed into the browser cache only.
* No duplicate requests. Each URL is fetched at most once per page view.
* Bounded network use. Configurable hover delay, concurrency cap, exclusions, Save-Data and slow-network respect.
* WordPress-native. Uses the WordPress enqueue and Settings APIs, nonces and capability checks on the admin page.
* No tracking, no telemetry, no hidden calls.

What is skipped automatically:

* External origins, mailto:, tel:, javascript:, data:, and pure #anchors
* Admin, login, logout, wp-json, cron, feed and trackback URLs
* Links with a download attribute and common binary file extensions
* Same-page links (nothing new to warm)
* Form submit-style links
* Any link (or ancestor) marked data-intent-prefetch="off" or class .no-prefetch

== Installation ==

1. Upload the projectstudios-intent-prefetch folder to /wp-content/plugins/, or install the zip via Plugins → Add New → Upload Plugin.
2. Activate the plugin through the Plugins screen.
3. Go to Settings → Project Studios Intent Prefetch and adjust behaviour (optional — sensible defaults are already active).
4. Open a public page, hover an internal link, and watch the Network tab: one prefetch appears after the configured delay.

== Frequently Asked Questions ==

= Does it work with page builders? =

Yes. It listens for pointer events on the document, so any link rendered by a theme, block editor, or page builder is covered without modification.

= Will it break my site if it fails? =

No. Every network operation is silent and best-effort; navigation itself is never touched, cancelled, or redirected.

= Does it send data anywhere? =

No. The only network activity is the visitor's own browser fetching same-origin URLs they chose to hover. There is no telemetry, no remote code execution, and no dynamic PHP.

= How is this different from WordPress's built-in speculative loading? =

WordPress 6.8 added a speculative loading API that prerenders or prefetches links according to a conservative ruleset. Project Studios Intent Prefetch is a lighter, intent-driven alternative: it warms the cache only for a link the visitor actually hovers or touches, with a configurable delay, a concurrency cap, Save-Data and slow-network respect, and per-link opt-out via `data-intent-prefetch="off"`. If you already run core speculative loading, both can coexist — this plugin never prerenders and never runs the fetched page's scripts.

= How do I exclude a single link? =

Add data-intent-prefetch="off" to that link (or to a parent container) and it will never be prefetched.

=== Screenshots ==

1. Settings → Project Studios Intent Prefetch: the switch, the hover delay, the concurrency cap, touch handling, and Save-Data / slow-network respect.
2. URL and path exclusions — your own fragments, on top of the core exclusions that are always enforced (wp-admin, wp-login.php, wp-json, feeds, and state-changing query parameters).

= Changelog ==

= 1.0.1 =
* Security: never prefetch URLs carrying state-changing query parameters (action, add-to-cart, nonce, rest_route, etc.).
* Security: never follow redirects during prefetch; redirected destinations are never requested.
* Fix: exclusions can no longer be wiped by WordPress double-sanitisation on first save.
* Fix: defer now emitted via the WP 6.3+ `strategy` API; minimum WordPress raised to 6.3.

= 1.0.0 =
* Initial release: hover/touch intent prefetch, dedupe, concurrency cap, exclusions, Save-Data and slow-network handling, Settings page.
