Skip to content

Commit

Permalink
Turn off Turbo prefetch for most links
Browse files Browse the repository at this point in the history
Instead of zeroing in on each link or link type to not pre-fetch, this
commit just disabled it for entire pages.

See: https://turbo.hotwired.dev/handbook/drive#prefetching-links-on-hover

I'm making this change, not because I've seen and measured that we're
seeing too much activity on the site. But, just out of a gut feel that
it's not worth the extra requests when hovering over links. We've
already got so many requests coming in just for the Game play itself!
So I'm just proactively making this change. Besides, the pages load so
fast on their own that the pre-fetch doesn't seem to add much of
anything.
  • Loading branch information
pdobb committed Jan 27, 2025
1 parent 8996f1c commit 874872a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/views/application/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
flex max-lg:flex-col gap-y-6
justify-between items-center
"
data-turbo-prefetch="false"
>
<nav class="lg:order-2 max-lg:w-full">
<ul class="flex justify-between items-center gap-x-24 lg:gap-x-8">
Expand Down
1 change: 0 additions & 1 deletion app/views/games/_listings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
engagement_tally: listings_date) %>
</h4>
<div
data-turbo-prefetch="false"
class="
grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 3xl:grid-cols-6
gap-y-1
Expand Down
8 changes: 5 additions & 3 deletions app/views/games/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

<%= turbo_stream_from(@view.turbo_stream_name) %>

<div class="container mx-auto space-y-12">
<div
class="container mx-auto space-y-12"
data-turbo-prefetch="false"
>
<div class="flex max-lg:flex-col justify-between gap-y-6">
<h1><%= title %></h1>

Expand All @@ -24,8 +27,7 @@
<%= link_to(
type.filter_name,
type.games_filter_url,
class: type.css,
data: { turbo_prefetch: "false" }) %>
class: type.css) %>
<span class="text-dim-lg">
(<%= type.games_count %> / <%= type.games_percentage %>)
</span>
Expand Down
5 changes: 4 additions & 1 deletion app/views/metrics/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<% title("Metrics") %>
<% description(t("metrics.meta_description")) %>

<div class="container mx-auto space-y-12">
<div
class="container mx-auto space-y-12"
data-turbo-prefetch="false"
>
<h1><%= title %></h1>

<% @view.engagements.tap do |engagements| %>
Expand Down
5 changes: 4 additions & 1 deletion app/views/users/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<% title(@view.display_name) %>
<% description(t("user.meta_description")) %>

<div class="container mx-auto">
<div
class="container mx-auto"
data-turbo-prefetch="false"
>
<div class="space-y-10">
<div class="xl:w-2/3 space-y-6">
<h1 class="border-b border-dotted border-dim">
Expand Down

0 comments on commit 874872a

Please sign in to comment.