James van Riemsdyk’s Philadelphia homecoming almost turned into a nightmare.

With his Maple Leafs cruising with a 3-1 lead midway through the third period, disaster struck when the ex-Flyer was called for hooking and holding penalties on the same play.

And when the Flyers Jakub Voracek beat Ben Scrivens on the ensuing power play to narrow the Leafs lead to 3-2, van Riemsdyk’s head could be seen sagging in the penalty box.

Fortunately, his Toronto teammates had his back this time around, just like JVR has had theirs on so many other occasions this season.

Hanging on over the final stages of the game, the Leafs were able to get an empty net goal from Jay McClement en route a 4-2 win over the Flyers, their second over Philly in the past two weeks.

The only thing quieter than van Riemsdyk in his first appearance in Philly since being traded to the Leafs last summer was the normally raucous crowd, which, like the Flyers, was held in check by a smothering Leafs team that featured a relentless tight-checking game plan that helped up the team’s road record to 8-4.

While the Flyers held JVR in check, the Leafs once again showed excellent scoring depth. After Phil Kessel had provided the team with a 1-0 lead in the first period, Nikolai Kulemin scored his second and Mikhail Grabovski potted his sixth for Toronto before McClement sealed the deal.

Grabovski has now scored three goals in his past four games, perhaps a sign that he is gearing up for Wednesday’s grudge match against the Montreal Canadiens at the Air Canada Centre.

The meeting against the Habs, of course, will be the first since the Leafs hammered the Canadiens 7-0 at the Bell Centre back on Feb. 9. On that particular evening, Montreal’s Max Pacioretty accused Grabovski of biting him during a scrum, an allegation that the NHL did not feel was legitimate enough to warrant a fine or suspension for the Leaf forward.

Ben Scrivens once again backstopped the Leafs to victory with James Reimer still on the shelf.

After staying out on the ice long after his teammates had finished the team’s morning skate on Monday, Reimer, admitting he had had another good day of practice, added the caveat that he would suit up to start a game only after the pain in his knee had subsided. As usual, he would not offer up a specific timetable, but the suspicion is that he’ll sit out several more days.

Scrivens, meanwhile, was prepared for the Flyers.

“One of my best friends is a Flyers fan, so I know how passionate the people who support Philly are,” Scrivens said after the morning skate. “I’m sure it’s going to be a lively building.”

Scrivens was asked if his acquaintance phoned him in the middle of the night Sunday night in order to get him off his game.

“No no,” he laughed. “I said she was my FRIEND.”

If he keeps winning like this, Scrivens will find himself with a lot of friends.