This mostly already happens automatically. If a text doesn't contain maths, then the processing bails out straight away (causing hardly any extra work). If a course doesn't contain a glossary, then the glossary dynalinking also stops early.
So it's not really a problem! But good thinking!