The Torah teaches us boundaries for consistent living. It restrains certain activities and expands other activities. The Torah is an instruction book. The Torah is a book of practical guidance for living. The final area, that being popularity, is quite tricky and very difficult to conquer without supporting accomplishments from the physical environment and spiritual experience.
Popularity deals with a person's insecurities.
Any person who learns theTorah has a degree of understanding of what G-d expects. When that person begins conducting their life in observance of what G-d expects they are more secure. They have fought small battles. They have been victorious in many areas of Torah observance. This provides a supporting foundation for combating popularity deficiencies.