5 ms·
Is the initiator documented anywhere? How come the browser uses it to draw the page?
by lrossi 6y ago
Is the initiator documented anywhere? How come the browser uses it to draw the page?
- gpnt 6y agoyes, the initiator is a valid HTML with a `<script>` pointing to the script that receives the JSON and render the page. The interesting part is you can `fetch` the page directly and it will respond a valid JSON.
- bluehex 6y agoOnce that script is kicked off it can get the current body of the page (the JSON) and replace it with html with: JSON.parse(document.body.innerText); document.body.innerText="" etc...
- achairapart 6y agoWhile the source looks like JSON, the page is still sent by the server as text/html. Browsers are so resilient to malformed markup that actually parse the content inside the <html> tag at the end of the document (firing the JS script that render the actual page), ignoring all the (pseudo) JSON around. The page is rendered in QUIRKSMODE because the source is missing the <!DOCTYPE html> at the beginning of the document, to resemble valid JSON. Well, at least that's clever!
- lrossi 6y agoThanks for the explanation. It makes sense, but sounds very fragile.