In today's world dieting is commonplace due to the abundant nature of fattening foods, but have any examples existed in the past?
This depends on what you mean by "dieting." If we're talking about managing diet as it relates to health, then this goes back to ancient times. Ancient Greeks practiced a form of humoral medicine that understood the bodily health as a relationship between the body and its surrounding environment, articulated through a balance of four "humors": blood, phlegm, yellow bile, and black bile. Each of these humors had different characteristics, being associated with different seasons and sensations like hot, cold, wet, and dry. Food also fit into these categories, so a food that mirrored the characteristics of phlegm (cold and wet) might be something like pickles or vegetables; a person ill because of an imbalance in their humors might eat this to restore that balance.
This understanding of humoral health continues through the Renaissance (see Ken Albala's Eating Right in the Renaissance), and arguably up through the "chemical revolution" in the late 18th century, when chemistry began to replace it. I've seen doctors using humoral terms through the 19th century, though, so it takes a long time before other ways of seeing diet and health eclipse it.
If we're talking about losing weight as the specific goal of dieting, then there are some fairly isolated examples before the 20th century. William Banting was a very obese Englishman who adopted what we would call today a "low-carb diet," lost a lot of weight, and then published books on the subject. However, the importance of such weight-loss strategies was fairly minor, because relatively few people were overweight. Indeed, until at least the 18th century, and in some places well into the 19th century (Ireland), famine remained a periodic problem. Even when famine was largely banished from the land, chronic malnutrition replaced it. In the Boer War around the turn of the century, for example, something like 40% of English recruits were turned away due to a variety of diseases or conditions, many of which were the direct result of diets poor in both quantity and quality. Working class Britons averaged several inches and ten pounds lighter than their middle and upper-class compatriots, for example, and both World Wars actually improved Britain's diet through rationing, despite overall shortages and price increases.
Still, by the 1930s, the wealth and food supply of the country as a whole had increased to the point that there was a subset of people who began looking for ways to lose weight. This was, initially, called "reducing," and Ina Zweiniger-Bargialowska has written extensively on the "reducing culture" of 1920s and 1930s middle-class Britons. It sounds quite similar to what we have today in many ways; by that point, there was a recognition of the thermodynamic properties of food, so that diets could be imagined in calories (or kilocalories, depending on which side of the Atlantic you're on) as well as micronutrients like vitamins and minerals.