Layout: Speculation Rules, prerender on hover
A <script type="speculationrules"> in the layout prerenders same-origin links with eagerness "moderate" (hover or press). Excluded: - cart, checkout, account, login, logout, wishlist, contact and the future /islands, plus the admin (/boboko) and /stoic - rel~=nofollow and [data-no-prerender] - listing controls that load into a Turbo Frame (sort, filters, pagination): links inside a <turbo-frame> or pointing at one, unless they break out with data-turbo-frame="_top" like the product cards Contact is excluded too, though the task didn't list it: it's a session page with hCaptcha. GA4 and a consent banner aren't in this repo, so no page-view delay on document.prerendering is needed yet. Add one when they're added. Watch production FPM after this deploy: until pages are cached, every prerender is a full PHP render, and there are only 8 FPM workers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bad5a7db69
commit
c1acc0067c
1 file changed
+36
@@ -45,6 +45,42 @@
|
||||
|
||||
@vite(['node_modules/@boboko/core/resources/css/checkout.css', 'resources/css/app.css', 'resources/js/app.js'])
|
||||
|
||||
{{-- Speculation Rules: prerender same-origin pages on hover or press.
|
||||
Excluded: personal/session pages (cart, checkout, account, login,
|
||||
logout, wishlist, contact, the future /islands), the admin and Stoic,
|
||||
rel=nofollow, anything marked data-no-prerender, and listing controls
|
||||
(filters, sort, pagination) that load into a Turbo Frame instead of
|
||||
navigating — i.e. links inside a <turbo-frame> or pointing at one,
|
||||
unless they break out with data-turbo-frame="_top" (product cards). --}}
|
||||
@verbatim
|
||||
<script type="speculationrules">
|
||||
{
|
||||
"prerender": [{
|
||||
"where": {
|
||||
"and": [
|
||||
{ "href_matches": "/*" },
|
||||
{ "not": { "href_matches": [
|
||||
"/:locale/cart{/*}?",
|
||||
"/:locale/checkout{/*}?",
|
||||
"/:locale/account{/*}?",
|
||||
"/:locale/login{/*}?",
|
||||
"/:locale/logout",
|
||||
"/:locale/wishlist{/*}?",
|
||||
"/:locale/contact{/*}?",
|
||||
"/:locale/islands{/*}?",
|
||||
"/islands{/*}?",
|
||||
"/boboko{/*}?",
|
||||
"/stoic{/*}?"
|
||||
] } },
|
||||
{ "not": { "selector_matches": "[rel~=nofollow], [data-no-prerender], turbo-frame a:not([data-turbo-frame=\"_top\"]), a[data-turbo-frame]:not([data-turbo-frame=\"_top\"])" } }
|
||||
]
|
||||
},
|
||||
"eagerness": "moderate"
|
||||
}]
|
||||
}
|
||||
</script>
|
||||
@endverbatim
|
||||
|
||||
@auth('staff')
|
||||
@php($stoicToken = \App\Services\Stoic::token(auth('staff')->user()->email))
|
||||
<script>
|
||||
|
||||
Reference in new issue
Block a user