tour_of_rust
tour_of_rust copied to clipboard
[FEATURE] Faster page loads
Currently when swapping between pages the page takes a second before any words appear on an old system at work here, it seems to be because of javascript loading (the rust iframe isn't even loaded yet so it's not the issue). Preventing the javascript from loading each and ever page load would allow swapping between pages a lot faster on slower systems and use less battery on mobile. There are a multitude of ways to do this but generally I opt for unpoly as it can be loaded on the page, then you decorate (just add some attributes to) some links that you want to it do a swap with and instead of the browser downloading the next page, reparsing the javascript, reloading the CSS, etc... it instead does a quick swap of the DOM elements, no reloading of anything else (unless you specify). You can control what is swapped as well though that's less interesting for pages like these. If you need to do something like run some javascript on elements when they get loaded it has a registry for that (think jquery-like matching but significantly faster, it doesn't use jquery). However there are other options, turbolinks is popular but it's less drop-in-and-work while being a lot slower.
Overall this would be a fairly minimal change and would decrease loading times substantially on lower-end hardware (especially as it can optionally prefetch the next page as well for instant swaps). And as it is decorative and enhancement only, the site still falls back to working as it does now when JS is disabled or the site is loaded in a browser without JS (like most CLI browsers).
@OvermindDL1 I tested it out and it looks interesting. It worked directly although I did not see any rust playgrounds (iframe). I didn't dig deeper into this library, maybe you know how to solve this problem.
The page load times are currently pretty good, I also optimized it with my last PRs. So this would be nice to have, but not mandatory anymore.
Edit: It seems to work with iframes. Rust Playground is at the moment just very slow for me. I will create a PR later.
It worked directly although I did not see any rust playgrounds (iframe). I didn't dig deeper into this library, maybe you know how to solve this problem.
It should work with iframe's, I use them with iframes without issue?
Edit: It seems to work with iframes. Rust Playground is at the moment just very slow for me. I will create a PR later.
Ah, yeah if the playground is slow not much can be done about that from the client. As long as the iframe loads it's contents asynchronously then it's fine anyway, which is the default in browsers.