Using iframes and document.write to improve navigation performance
jakearchibald.com
jakearchibald.com
Devil's Advocate: maybe the real answer is to go back to proper full-page loads and figure out why your javascript and CSS parsing is taking so long.
One technique I didn't cover (as the article was getting long) is using a service worker to speed up server renders. The test & code can be found at https://jakearchibald.github.io/streaming-html/
Arguably a little bit clickbait-y, as the headline is accurate but doesn't mention the streaming JSON idea that's covered in the same article. That's a much more sensible approach than abusing iframes.
And as the article also says, you'll get the benefit of progressive rendering for free if you just don't make your site into a single page app in the first place.
One paragraph per chunk?
I suppose you could implement some kind of SAX-like thing expressed as ND-JSON…
…orrrrrr avoid all that by streaming HTML.
But if I were charge of a magazine and ran it that way, it would quickly die from lack of ad revenue, oh well. :/
right?
It feels like open heart surgery with a rusty knife. But I can't find anything in the specs saying that it is verboten.
The trick here is that the the invoked behavior is spread over the HTML5 and DOM specs and maybe a little Ecmascript too. In isolation they appear sane, combined together they are loose enough that this hack does not run afoul of any rules.
It doesn't guarantee the payload will load faster, especially on mobile. Obviously, the solution is to avoid loading large ajax responses and only returning from the server what is absolutely needed.