For most people, when they cook, oil is the first thing they reach for. This is entirely unnecessary and just adds empty calories to your food.
The purpose of frying is to bring out the natural flavors and oils in food. Most often, people fry onions and garlic to start a dish. Instead of oil, use a couple tablespoons of water.
Some people call this "water frying." The water will evaporate but will cook the onions and garlic enough to release their natural flavors and oils.
They will still brown. Depending on your pan, they may stick, but this is nothing to worry about. Anytime you sautee onions and garlic, it is likely the base for something like tomato sauce. When you add the tomatoes, the liquid will pull those stuck pieces right into the sauce and take on all that flavor.