I came across this Javascript tool which does HTML inspection to look for issues.
The tool itself is quite advanced as far as adding custom filters and options, but the defaults are also fine.
https://github.com/philipwalton/html-inspector
Using their CDN and code, I wrote the smallest little plugin to put this into my project globally.
Create a plugin called "HTML Inspector" or whatever you like. Insert this code:
<?php
// reference the output
$output = &$modx->resource->_output;
$output = str_replace("</body>",
'<script src="http://cdnjs.cloudflare.com/ajax/libs/html-inspector/0.8.1/html-inspector.js"></script>
<script> HTMLInspector.inspect() </script>
</body>',
$output);
Attach the plugin to the system event "
OnWebPagePrerender" which would be at the bottom of the list.
Only enable this plugin during development, as it will slow down page load a little bit.
To use it, just open your web browser tools and open the console. The tool outputs any issues to the console that it finds in your HTML source.
The plugin itself simply looks for the closing "</body>" tag and inserts the two scripts above that.
If you wanted to limit tests to only certain pages or contexts or parent tree, etc, you'd have to edit it further for your needs.
----------------
This is a very generic way to insert scripts globally into code. I initially used this script by editing my templates, but then I also had to edit my footer chunks, and deal with user auth logic and snippets. I ended up having to put code in 4 places to use this. This would be a pain to have to come back and remove whenever I don't need the tool.
By using a plugin, it loads on every page, and I can just disable the plugin when not needed.
This use of a plugin, on page prerender, is a good generic way to load scripts globally with a single enable/disable function. It helps me avoid putting "temporary" scripts into my templates/chunks/snippets that I have to remember to remove again later.
There may be an existing plugin that does this sort of thing more elegantly, but based on how easy this was, I just did it myself without even searching for something better.