Justin Timberlake released Friday a new song called “Can’t Stop the Feeling.” Above, Timberlake appears at the 2014 iHeartRadio Awards presentation in Los Angeles. Kevin Winter/Getty Images

The vibe Justin Timberlake is shooting for with his new single is clearly “Happy.”

Friday, the actor and singer released his first piece of music in almost three years, a song called “Can’t Stop the Feeling,” which was written for “Trolls,” a DreamWorks Animation film scheduled for release in November. Thanks to pent-up demand for new Timberlake material and social media support from the movie's star-studded cast, “Can’t Stop the Feeling” quickly zipped to the top of the song charts over the weekend, according to BuzzAngle Music. In doing so, it sped past Drake’s monster hit “One Dance” and new songs by Alicia Keys, Calvin Harris and Ariana Grande.

Timberlake, who voices one of the characters in “Trolls,” would certainly like his song to do well: He’s going to be on the Eurovision Song Contest stage in Stockholm Saturday, his first musical appearance in quite a while. But because the new song’s attached to “Trolls,” there’s a corner of the DreamWorks camp that is surely hoping that “Feeling” follows the same trajectory as “Happy,” another song that rode its place in a family-friendly film to sustained success.

It is not an exaggeration to say that “Happy” is the biggest solo hit Pharrell Williams has ever had. The song had gone platinum before Williams’ solo album, “G I R L,” was even released, and it went on to go platinum another six times, making it the top-selling song in the performer’s career. At one point, people were suggesting that “Happy” become the official state song of Virginia.

It also began to take off just as “Despicable Me 2” was starting to make its way onto Blu-ray Disc and DVD shelves, a nice boost for a movie that made close to $1 billion at the box office — and about $250 million in Blu-ray and DVD sales in the U.S. alone — according to the box office research firm The Numbers.

In this case, DreamWorks is likely hoping to ride JT’s coattails earlier in the process. Unlike “Despicable Me 2,” a much-anticipated sequel to a breakout hit, “Trolls” has nothing to recommend it besides some dubious brand recognition and, again, a prominent association to one of the most winsome, well-liked pop stars in recent memory. Sounds like something in need of positive feelings.