From Shakespeare and Austen through Tracy and Hepburn, when it comes to romantic comedies, chemistry is king. It’s one reason the rom-com has long seemed like the toughest code for Hollywood to crack.

But never underestimate the power of snappy, rapid-fire banter, the paving stones of the Hollywood road to romance.

That’s another way of saying “Friends With Benefits,” the R-rated romantic delight of the summer, had me the moment Mila Kunis’ character passes a poster for the failed rom-com “The Ugly Truth” and utters this immortal line: “Shut up, Katherine Heigl, you stupid liar!”

“Friends” pairs Kunis, as Jamie, a New York corporate recruiter (“head hunter”), and Justin Timberlake as Dylan, a Los Angeles editor she hunts, hires, befriends and eventually tumbles into bed with — a friendship with sexual benefits. Yeah, it’s like “No Strings Attached.” Only better. Snappier.

The not-quite-lovers “meet cute,” in the classic Hollywood style.

“I’m from LA,” Dylan chirps, in New York to see if this job at GQ Magazine would be a good fit. “I like my open spaces.”

“What are you, a gazelle?” Jamie shoots back.

Will (“Easy A”) Gluck’s movie — script by Gluck, David A. Newman and Keith Merryman — is all about the New York/LA conflict. Everybody in NYC yanks poor Dylan’s chain — sarcastic, biting put-downs, fake threats and come-ons.

There’s Woody Harrelson, cast against type as the butch yet over-the-top gay sports editor, and in a hilarious cameo, gonzo snowboarder Shaun White repeatedly scares the bejeezus out of the overmatched Dylan. No wonder he clings to Jamie, his first friend in New York. She’s into weepy romantic comedies, which they watch together.

“Why don’t they ever make a movie about what happens after the kiss?”

“It’s called porn.”

Being young and good-looking and married to their jobs and so frequently burned by other relationships, naturally they tempt fate by trying the sex-without-complications thing.

Take an oath on that. On a Bible. “They have an app for that. Swear-on-your-Bible app, ‘No relationship!”‘

Gluck knocks us on our heels with the film’s opening scene — dueling breakups (Andy Samberg is the guy doing Jamie wrong, Emma Stone of “Easy A” shrieks her way out of an affair with Dylan). Later, Richard Jenkins, Patricia Clarkson and Jenna Elfman show up in tiny but funny roles as relatives.

And the stars pick it up from there. Kunis already has sitcom-ready timing, and the editing makes the zingers just zing by. Dylan leaves his socks on during sex — “I can work with that,” she says. But this sex-not-love thing “seems a little college-y” to her.

“I could sing a little Third Eye Blind,” he fires back. Then Timberlake croons a little “Closing Time.” By Semi-Sonic. Not Third Eye Blind.

They finish each other’s sentences and read each other like books — comic books.

“Every time you curse, you blink. It’s as if your body’s rejecting the word.”

Will they find each other promising enough to move beyond mating to mating? What do you think? Yeah, we all know the formula. But when it works and the chemistry is just right, we love seeing exactly what we expect and hope for.

With “Friends With Benefits” after “Easy A,” Gluck is now two-for-two. Hollywood could have its new romantic comedy king. But only as long as he avoids the charms of Katherine Heigl.