Post-processing Page-Output

I wonder if the approach used in the kirby-minify-html plugin could work for you. I am not quite sure how the plugin hooking into the ‘template’ config compares to the Page Model approach outlined above, including the wish for it to happen pre-caching…

It sounds like your desire to clean up the final HTML code is very similar to the strategy of HTML minification. Maybe this discussion is of interest to you?