Skip to content

Commit

Permalink
Prefetch on demand (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
Spomky authored Mar 9, 2024
1 parent 6705958 commit d051583
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions assets/src/prefetch-on-demand_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@ import { Controller } from '@hotwired/stimulus';

/* stimulusFetch: 'lazy' */
export default class extends Controller {
static values = {
urls: { type: Array, default: []}
};

connect = () => {
prefetch = ({params}) => {
const workbox = window.workbox;
if (!workbox) {
if (!workbox || !params.urls) {
return;
}

workbox.messageSW({
"type": "PREFETCH",
"payload": {
"urls": this.urlsValue
"urls": params.urls
}
});
}
Expand Down

0 comments on commit d051583

Please sign in to comment.