While the NFL gets socked with ratings declines, the NBA is off to its second-most-watched season ever.

ESPN, which has telecast 30 games since the season’s Oct. 17 opener, said Thursday that average viewership has soared 18 percent, to 1.8 million a game, from this point last year.

TNT, with 16 NBA telecasts to date, said its average is up 25 percent, to 2.1 million viewers. Even NBA TV, with 41 telecasts, is up 25 percent, to 365,000.

The averages, taken collectively, make for the hottest start since the 2010-11 season — the year LeBron James abandoned the Cleveland Cavaliers for the Miami Heat.

Central to the NBA’s rise is its success in focusing the league’s many dramas on the game itself — an area where the NFL has failed miserably, experts say.

“NBA stars don’t wear helmets, so fans think they know them better by watching their features and their gestures,” said Ben Sturner, president of sports marketer Leverage Agency. “This sense of familiarity plays really well with the social media set.”

Meanwhile, the NFL is being penalized for a lack of focus, according to Sturner.

Its story lines these days encompass a panoramic sweep of protest rights, brain-damage risks, squabbling owners, media oversaturation, even subpar play.

“You don’t get any of that at basketball games,” Sturner said. “You just get action.”

Given all the cord-cutting in the intervening years, not to mention the indifference of millennials to traditional TV, the NBA is clearly doing more than a few things right.

Experts point to last season’s rousing finale — a five-game face-off between the Golden State Warriors and the Cleveland Cavaliers — which gave the NBA its best ratings since Michael Jordan quit the game in 1998.

The league followed its early-June finals with the “2017 NBA Draft” on June 22 at Brooklyn’s Barclays Center.

ESPN’s telecast of the event drew 15 percent more viewers than the previous year’s version, making it the second-most-watched NBA draft on record.

In July, the NBA’s expanded Summer League started introducing drafted players to a broadening fan base.

ESPN telecast 25 of the summer games, generating an average viewership of 437,000 — up 51 percent from the previous summer.

Meanwhile, a host of offseason trades extended the NBA narrative.

Nine-time All-Star Chris Paul was traded to the Houston Rockets in June in a deal that gave the Los Angeles Clippers seven players in return.

Point guard Kyrie Irving jumped to the Boston Celtics in August after inexplicably asking to exit the Cleveland Cavs in July.

“Every day seemed to bring another story line for fans to follow,” ESPN spokesman Ben Cafardo said.

The NBA’s offseason happenings have given the league an all-year presence, creating a virtuous circle other pro sports can only dream about.

“We’ve gone from most-watched finals on ABC, to second-most-watched draft, to most-watched Summer League and now to second-most-watched start,” Cafardo told The Post.