Ribbon customization can be done using Ribbon Workbench.
In Ribbon Workbench window, select entity that will have dynamically loaded ribbon, and add new Rule.
When adding new rule, choose Value Rule.
This rule should be associated to the Command and to the Button that triggers that command.
InvertResult of False is True, so the rule above means that the button will be loaded when the value of the field new_subject is “Hello World”.
You can add multiple value rules, or you can make a combination of rules, and define that some button will be displayed if one OR another condition or group of conditions is met.
refreshRibbon is predefined
Xrm.Page.ui method that causes ribbon to re-evaluate data that controls what is displayed in it.
After saving and publishing changes, defined Ribbon Button will be displayed only if the condition is met.