LOS ANGELES — Two bunts to the left side of an infield that was wide open thanks to an aggressive Dodgers shift in the ninth inning might have been head-scratching to some, especially after the second one resulted in a strikeout when it went foul. It made perfect sense, however, to the bunter who had homered twice Friday night.

“If they are going to give it to me and I get on base for the team, I don’t think it is a bad idea,’’ Didi Gregorius said after the Yankees dropped a 2-1 decision on Saturday at Dodger Stadium.

Leading off the ninth inning against closer Kenley Jansen, Gregorius looked at the third-base area, which was devoid of a defender, and attempted a bunt that barely went foul. Undaunted, Gregorius tried it a second time, but when that went foul he was out.

“If the first one is fair it is probably a double,’’ Gregorius said. “I am a team player trying to get on base.’’

Manager Aaron Boone said he wouldn’t tell a player to take a stab at a bunt single with two strikes, but he didn’t second-guess Gregorius’ decision.

“I had no issue with it. I would never tell someone in that spot [to bunt], but I thought it was a good play and almost had a leadoff double,’’ said Boone, whose team was held to five hits. “What are your chances of getting on base there? With two strikes, you are down a little bit and I thought he was very close to executing it. It’s a weird way to end, but when you break down the play I don’t think it is a bad thought if you are confident you can do it.’’

Aaron Judge’s fourth-inning homer was the Yankees’ 58th homer in August, which leads the majors in the month and is a franchise record. It also tied the major league record for homers in a month previously reached by the Orioles (May 1987) and Mariners (May 1999).

The Yankees also broke a tie for second place on the all-time list when Judge homered. It pushed the Yankees’ streak to 213 games with at least one run scored and broke a tie with the Brewers. The Yankees (1931-33) hold the record with 308.