If you are talking about petroleum based gels, this is a bad idea. Those hairball remedies interfere with nutrient absorption and should never be given with food. They should be given on an empty stomach at least 2 hours before a meal.
Better yet, don't use them at all, they are toxic. Petroleum was never meant to be ingested, by anyone, including cats.
Instead, feed a good quality canned (or raw) diet, brush daily, and use egg yolk lecithin for hairball control.
Egg yolk lecithin is a fat emulsifier. This means it breaks down the fat that is holding the fur together to make the hairball (that is what a hairball is, mostly fur held together with fat)
Start them on a half capsule twice a week, increase the dose gradually if necessary.
Do not use soy lecithin, it has to be egg yolk. Soy is also bad for cats. There are two brands of egg yolk lecithin, Swanson and Nature's Plus.