Skip to content

Commit

Permalink
AO3-6636 Add speculation rules next-chapter prefetch (#4661) (#4665)
Browse files Browse the repository at this point in the history
* AO3-6636 Add speculation rules next-chapter prefetch

* Add lint config

* Indent

* Put behind a rollout

Co-authored-by: Domenic Denicola <d@domenic.me>
  • Loading branch information
sarken and domenic authored Nov 20, 2023
1 parent 690e9c0 commit 942f4a3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .erb-lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
EnableDefaultLinters: true
linters:
AllowedScriptType:
allowed_types:
- "text/javascript"
- "speculationrules"
DeprecatedClasses:
enabled: true
rule_set:
Expand Down
14 changes: 14 additions & 0 deletions app/views/chapters/_chapter.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@
</div>
<% end %>

<% if @next_chapter && $rollout.active?(:prefetch_next_chapter) %>
<script type="speculationrules">
{
"prefetch": [
{
"source": "list",
"eagerness": "eager",
"urls": ["<%= work_chapter_path(@work, @next_chapter, anchor: "workskin") %>"]
}
]
}
</script>
<% end %>

</div>

<% end %><!-- end of cache -->

0 comments on commit 942f4a3

Please sign in to comment.