At one point, Federer had won 35 consecutive points on his serve as Lacko simply struggled to contend with the reigning and defending Wimbledon champion.
The 36-year-old destroyed Slovakia's Lukas Lacko 6-4 6-4 6-1 in 90 minutes on Centre Court.
"I think it is important that, when you want to serve well, your point-for-point mentality is right", Federer said.
Serena Williams progressed into the third round with a dominant straight-set win over Bulgaria's Viktoriya Tomova.
It was another dominant display by the eight-time champion, who lost just nine of 61 points on his serve in total and broke Lacko five times, including with a forehand victor to close out the match. "Sometimes your serve matches up better against certain players".
Serena, seeded 25th after her return from maternity leave, faces France's Kristina Mladenovic or Germany's Tatjana Maria for a place in the last 16.
It was a bitter defeat for the 27-year-old Dane, who was expected to challenge for the Wimbledon title after winning her maiden Grand Slam crown at the Australian Open in January. But she was broken again in the final game, becoming the fifth of the top eight women's seeds to lose before the third round.
Netflix is Testing a New High End Ultra Plan
For less than $14 a month, you can enjoy all the movies and TV shows you like, in Ultra HD, on up to four devices simultaneously. A Philippines-based user "fat Dudan" tweeted that Netflix Philippines did not have Peretti's stand-up show One of the Greats.
Five-time champion Venus Williams battled into the third round with a 4-6, 6-0, 6-1 win over Romanian qualifier Alexandra Dulgheru.
In the first round, she started by conceding a tiebreaker against 58th-ranked Johanna Larsson before taking 12 of the last 15 games.
However, that didn't appear to be affecting her as she rallied to level the match by winning the second of two closely fought sets.
After losing just one set on her way to the Wimbledon title a year ago, Garbine Muguruza picked up exactly where she left off, beating British wild card Naomi Broady 6-2, 7-5 on Tuesday.
Former world number one Karolina Pliskova finally made it to the third round on her seventh visit to Wimbledon after seeing off two-time Australian Open champion Victoria Azarenka 6-3, 6-3.
Lucas Pouille became the latest seeded player to exit the men's draw after a 6-4, 6-2, 6-7 (8), 3-6, 6-2 defeat to Austrian qualifier Dennis Novak.
American Jack Sock, seeded 18th, was up by two sets but still lost 6-7 (5), 6-7 (3), 6-4, 7-5, 6-2 to Matteo Berrettini.