Templates for modules

Is there any way to apply what modules should be active on certain device OS or device group etc?
I’m not sure if this is possible through config.php but it seems like it would be a good addition to have in general.

Ability to define templates in the system for it just like alert templates.
Is there any benefit in terms of speed for polling/discovering if certain module is not active?