A year ago, Meta's stock was in the midst of a nosedive as Wall Street grew concerned that threats to the business were increasingly existential. But after Mark Zuckerberg's company, formerly known as Facebook, reported better-than-expected second-quarter results last week and issued optimistic guidance, Meta shares jumped to their highest since early 2022. Despite slipping on Monday, Meta's stock climbed 11% in July, wrapping up its ninth straight month of gains, by far the longest such stretch since Facebook's IPO in 2012. The stock is now within 17% of its record high from September 2021. Driving the dramatic rebound is a series of cost-slashing measures Meta implemented in late 2022 and early 2023 resulting in about 21,000 job cuts, and a recovery in Facebook's online ad business, which is finally back to double-digit growth after Apple's iOS privacy change and a sputtering economy led to three straight quarterly sales declines. Meta's investments in artificial intelligence are also paying off, more people are watching short-videos on the company's TikTok-like Reels product, and the recent debut and early adoption of the Twitter rival called Threads has given investors hope that Meta can eventually turn the messaging app into a major hit. Zuckerberg said on last week's earnings call that he's "quite optimistic" about Threads and its trajectory, noting that the product "was built by a relatively small team on a tight timeline." He added that Threads "really blew up and created a big opportunity immediately," but went on to suggest that the company is nowhere close to trying to monetize the app. "With easing comps, continued AI-driven improvements to targeting capabilities, and several exciting nascent products and monetization initiatives, we think the ongoing Meta turnaround has a long runway ahead," wrote analysts at Canaccord Genuity in a note after Meta's earnings report. They have a buy rating on the stock. Threads is not the reason why Meta's stock is up, Ritholtz's Josh BrownWATCH NOW VIDEO05:29 Threads is not the reason why Meta's stock is up, Ritholtz's Josh Brown Meta has been the second-best performing stock in the S&P 500 this year, behind only Nvidia . Last year it was one of the worst performers in the index, losing two-thirds of its value. Kicking off the downward spiral were the stunning revelations in late 2021 from former Facebook employee turned whistleblower Frances Haugen. Haugen's leaking of thousands of pages of internal documents showed that Facebook had failed to address various problems affecting its family of apps, such as Instagram's contribution to the mental health issues of teenagers. The public outrage over the revelations put Zuckerberg once again in the crosshairs of lawmakers, further damaging Facebook's reputation after years of concerns with how the platform handled misinformation. As Facebook shares began their descent, Zuckerberg renamed his company to Meta, and told investors of his plan to spend billions of dollars a quarter developing the virtual and augmented reality technologies needed to bring the so-called metaverse to life in the distant future. The Apple headwind The biggest problem was Apple. Although Zuckerberg and other company executives had warned that the iOS privacy update would hurt Facebook's ability to effectively target ads, investors only digested the reality of the situation as earnings reports came up short. The company also felt the repercussions of the war in Ukraine and Russia's blacklisting of Facebook and Instagram in the country. While Russia only represented about 1.5% of overall sales, Meta needed all the revenue it could drum up with advertisers pausing spending because of the shaky economy and competition picking up from rival TikTok. Meanwhile, Wall Street was growing increasingly concerned about the company's profligate spending on the metaverse. Then came the cost cuts and Zuckerberg's promise early this year that 2023 would be the "year of efficiency." Zuckerberg previously told employees that Meta was "taking a number of additional steps to become a leaner and more efficient company by cutting discretionary spending and extending our hiring freeze through Q1." "I want to take accountability for these decisions and for how we got here. I know this is tough for everyone, and I'm especially sorry to those impacted." Zuckerberg wrote in November of last year. Under Meta's cost-cutting plans, Zuckerberg said this year that the company would remove layers of middle management that he believed was slowing down important decisions and the company would be "proactive on cutting projects that aren't performing or may no longer be crucial." The financials started looking better in the first quarter, as sales grew 3% from the prior year. Much of the bounce was coming from China, where a national easing of tough Covid policies led to a boom of Chinese companies spending heavily on Facebook and Instagram ads to target users worldwide. Nurphoto | Nurphoto | Getty Images Meta executives pointed to several positive signs that its business was on the mend. More companies, particularly retailers, were spending money on Meta's AI-powered Advantage Plus service, helping restore the effectiveness of its online advertising system. The company touted the increasing use of its short-video Reels service. Reels continues to grow while TikTok's future in the U.S. remains uncertain as lawmakers scrutinize the app, which is owned by China's ByteDance, for alleged national security issues. Even as the stock pushes higher, plenty of concerns remain about the future of Meta. The company's Reality Labs unit, home to its metaverse investments, lost $13.72 billion last year and another $3.7 billion in the first quarter of this year, all while sales remain miniscule. Apple has recently jumped into the VR market with promises of a new headset. On the ad side, Amazon's business continues to ramp up, and TikTok could still be a threat if it can escape regulatory woes. Governments around the world are still scrutinizing Meta over data privacy and related issues. Meta CFO Susan Li said last week that there are "broadly speaking, increasing legal and regulatory headwinds in the EU and the US that could significantly impact our business and our financial results." But for the time being Meta investors are celebrating, and the picture is clearly much brighter than it was 12 months ago.