New Jersey’s best offensive performance in nearly a month, coupled with a second consecutive standout performance from goaltender Johan Hedberg, translated into a commanding 5-2 win over the Flyers Wednesday night in front of a sold-out crowd of 17,625 at the Prudential Center.

The Devils (13-9-5, 31 points) have won three of four after an 0-5-1 stretch, and moved into a sixth-place tie with the Maple Leafs.

“Like I said during the losing streak, I thought we played well enough to win some of those games,” DeBoer said. “For different reasons, they didn’t go our way. We felt if we would stick with it, try and keep a positive outlook, that it would turn, and it has.”

Prior to the game, DeBoer said his team needed to have more of a shooter’s mentality rather than waiting for the perfect opportunity. If the Devils can score goals at such a close ratio to their shot attempts, it won’t matter. Facing Ilya Bryzgalov, who allowed three goals on the first nine shots he saw, helped, too.

“I thought we played the right way from start to finish,” Henrique said. “We played a solid team game. We stuck to our system, we were getting pucks to the net, we got a couple of bounces our way. It’s a huge win for us.”

The Devils couldn’t have scripted a better first period, aside from the three penalties they took.

Henrique’s forecheck led to a giveaway and Elias’s ninth goal of the season on a goalmouth backhand, at 2:02 of the period. Jakub Voracek pulled the Flyers even on the man advantage, ripping home a Wayne Simmonds cross-ice feed past a helpless Hedberg on a half-empty net.

Just as the Flyers were done celebrating, however, Henrique snuck a right post a wrist shot past Bryzgalov 36 seconds later, and the Flyers seemed to be in position to pull even on the power play again later in the period. Instead, Kovalchuk scored shorthanded magic, jumping on a Stephen Gionta pass off the boards and speeding past Andrej Meszaros like he was a bystander for the 50-50 puck before beating Bryzgalov near side for a 3-1 lead.

“They made a couple of mistakes, we were patient and capitalized on them obviously,” Elias said.