in reply to
There is actually already a module which does something like what you're looking for, called HTML::Clean.
There is one big difference between it, and the solution you are working on. Your solution modifies the files directly while still on your disk. It may make them hard to read when you need to maintain them, but no extra processing is required when a browser requests them.. so it may be a bit faster then the method the module uses.
I personally prefer using this module, as it makes code maintenance much easier. However, the best method definitely depends on the requirements of your project. If obfuscation of the source files on your disk is what you're looking for, this might not do the trick. This only "obfuscates" the code as users view it in their browsers. But if you use a regex to obfuscate your code, someone can just as easily use a regex to unobfuscate it :-) Good luck!