3 ms·
My own website is a kind of hybrid SSR/SPA in PHP. Navigating pages with JS enabled (JS is entirely optional) seamlessly updates the relevant DOM nodes with an
by jimmaswell 3y ago
My own website is a kind of hybrid SSR/SPA in PHP. Navigating pages with JS enabled (JS is entirely optional) seamlessly updates the relevant DOM nodes with an AJAX call (and uses the history API etc), but going to a page fresh is entirely PHP.
It was fun to write. Relevant code is here:
https://github.com/ldyeax/jimm.horse/blob/master/j/j.php https://github.com/ldyeax/jimm.horse/blob/master/j/j.php
https://github.com/ldyeax/jimm.horse/blob/cb6a1c03504cbe6b638e0fcf91d4674fc9d7c68b/j/component/header.js#L68 https://github.com/ldyeax/jimm.horse/blob/cb6a1c03504cbe6b63...
I actually uncovered a niche bug across multiple browsers with this PHP code. In at least Firefox and Edge, if a page is cached with a fetch using accept:text/json, the response will be shown from view-source of the html page you have open, even if the content is different when you fetch the page with accept:text/html