The Javascript code in the article is server-side and not essential - it's just one way to take advantage of open shadowrootnodes and it could be written in PHP or anything else. It's showing how you can output your HTML in a very different order, with arbitrary delays, and still get the page layout you expect.