The browser CRP, or Critical Rendering Path, is the fundamental sequence of steps required to get the "glorified text files" of HTML, CSS, and JS, from lines of text in a file, to pixels in a browser.
A HTTP request-response cycle results in a HTTP response body containing a HTML string.
Parse the HTML and use it to generate the DOM (Document Object Model) in the browser. This is an incremental process that can involve additional requests for additional payloads that affect the construction of the DOM. For example, additional CSS and JS files can be requested, and the JS file could itself manipulate the DOM.
Further parsing of the HTML, this time focused on CSS and generating the CSSOM in the browser
Processing the DOM and CSSOM to determine what is to be rendered, thereby generating the "render tree".
Use the "render tree" of what ought to be rendered, and process it to calculate what the layout of the page ought to be, accounting for z-index layering, entity widths and heights and colors, etc. This is the "layout tree".
Turning the "layout tree" into "painted pixels" in the browser. I'm unaware of a name for this step.
nodejs on the server. You could then
<script> tags would all have python code in them. Browsers would then implement DOM APIs in python and provide them to you by default when they executed your python scripts. You would be able to create div elements, and add text to them, all with python code.
Here's a hypothetical. I wave a magic wand and have multiple languages supported as scripting languages in the browser. Fundamentally this means a subset of "secure" standard library functions, and an extension to support the DOM APIs. Your entry point text file could then declare it's scripting env. This could be like
.sh files on the OS do it, so instead of
#!/usr/bin/env python you could write
#! /languages/python (browsers would implement whatever is in this pseudo-location). Alternatively, you could add an attribute to a script tag.
<script lang="python" src="main.py"></script>
Imagine the following, and you can replace
python with any other language (supported by the browser).
<html> <body> <div id="root"></div> <script lang="python" src="main.py"></script> </body> </html>
# main.py import dom root = dom.document.getElementById('root') child = dom.document.createElement('p') child.innerText('hello') root.appendElement(child)