-
Long story made short: Current project I'm working on I have basically a 'kiosk' application with remote control via a JS EventSource setup. As of right now just doing the loadPage aspect I can get it to work well and very reliably getting that control signal from ES and calling loadPage to load a new page via Swup. What I'm trying to add onto this is when one of these calls comes in, I want it to wait and preload/cache the new page first and then do the loadPage once the preload is complete. My JS knowledge is fairly lacking and I've been hacking most of this together as I go along. Here's the core section of the script I'm working with in the latest iteration/attempt to get this working:
I've also made sure to turn 'on' the pagePreloaded event in my main swup script:
What I've noticed in testing and watching the console is upon receiving the remote command, it seems to fly through the preloading messages I've added in above. I'll get If it helps, the following link is the active repo I'm working with and the file where this is taking place in, though it doesn't have the current code above. It's a Django based project and all of this is happening within the HTML templates and associated static JS/CSS assets. All pages being loaded are 'dynamic' through the Django platform but each page has its own unique URL. I've been messing with this off and on the past few months and tried different attempts and options, including doing a dumb times delay between preload and loading in the page that didn't seem to work reliably either. So I'm at a loss and checking in here. I've also come up empty finding any similar examples to this that I can learn from. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
What's the advantage of preloading the page before actually loading it? Shouldn't it be just as fast by loading without preloading first? It's the same request. |
Beta Was this translation helpful? Give feedback.
What's the advantage of preloading the page before actually loading it? Shouldn't it be just as fast by loading without preloading first? It's the same request.