Ask them to be part of the solution. Most of them will turn red and shut down. The biggest critics out there are all talk and no do. I saw a woman criticizing a mother who had to return to work after giving birth to make ends meet. I said to this woman “if this is such an issue for you, why don’t you start a charity that assists those with children with their bills so a parent can afford to stay home?” No response. Someone calls you unhealthy, ask them what healthy recipes they’d recommend, better yet, let’s go shop for those ingredients. They may try to retort with “that’s not my responsibility!” Then you say “then you shouldn’t have said anything to begin with.” This makes you seem more assertive and is the best repellant for people who want to shit on you.
That being said, please use this method with caution because it can backfire. You don’t want to end up pushing away someone who is genuinely trying to help you. This is more for dealing with shitty people who project their insecurities and negative thoughts onto you and projecting it right back to them. If something is actually your fault and is affecting other people, take accountability. Only use it on people you don’t mind walking out of your life.