There are different kinds of hecklers. There are those who are just chatting with you out loud, which is annoying, but not mean. Sometimes, this is the type of person that you can talk with, give them something to do, jokingly request that they let someone else have their say, etc, and end the problem.
Then there are the jerks. These are rare (except in schools) and it is very hard to give good advice for dealing with these.
School is a horrible place to do magic, but if you can learn to handle it, you can learn good audience skills. I teach at a middle school, and I figure 80% of the kids in the building would fail miserably at performing at school, because of hecklers. Most of these kids are not unpopular. Hecklers are the kids who do not like others to be the center of attention.
The key to any performance is not simply to expect people to politely watch you because you like magic. Would you stop them on the street and ask them to listen to you sing? Why should you with magic? If you want to people to watch you, you better have a good show. Obviously, if you are new, you will not have a good show yet, so you may suffer for a while. All I can say is, be patient. It is not that bad when you do this away from school. Also, since you are just doing tricks, which is OK, only do magic for select friends and only do it when you are asked and do it where others can't come by and watch. Maybe you should do it at home.
As far as the "you should be good enough to never get caught," notion, that is unrealistic, particularly in a school setting. If you have absolute control over the audience, angles, etc, then maybe you can be perfect. But even the greats get caught. Gazzo, who works the streets in front of hundreds, surrounded, and who is one of the best, will get caught. I use the same size balls for the cups and balls he uses, 1 1/4 inch, and sometimes people spot them, particularly if you are surrounded. You live with it. Sometimes, people know about the TT. Of course, a spectator will usually yell out, "He has a fake thumb!" Gazzo would simply say, "Yea, and a fake hand and fake nose and fake feet..." or whatever. Most people do not know what the heckler is talking about, so they can't follow the point. Just go on. You have to control the situation.