8. Waiting for the browser
In exercise 1, we were a little sloppy for the sake of simplicity.
Generally speaking, you don’t want the browser to start running your stylesheet before the page is ready. One way to make sure that doesn’t happen is with this incantation:
<script>
window.onload = function() {
SaxonJS.transform(
{ stylesheetLocation: "ex02.sef.json" },
"async");
}
</script>
(There are other options, including putting the script elements
at the end of the body
element or using an explicit
event listener. This is a relatively simple alternative.)