Facebook (NASDAQ:FB) stock has been climbing to new heights as we near the company's second-quarter earnings report, and investors may be champing at the bit to buy before earnings to capitalize on what's expected to be a big quarter.

Source: Wikimedia Commons

As a Facebook shareholder, I'll admit it's crossed my mind. But I'm standing pat until the world's largest social-media network reports earnings July 29, and I'll tell you why.

Lots of good stuff going on
Facebook gave us a number of reasons to be optimistic in the last quarter. Advertising revenue -- where the company makes just about all of its money -- rose by 46%.

Perhaps even more important: Mobile ad revenue was up a whopping 82%. Progress in mobile ads is crucial, as the smartphone continues to make up a bigger share of our Internet use. And no company has done a better job so far in figuring out mobile advertising than Facebook has -- not even Google. Mobile ads made up 73% of Facebook's ad revenue in the last quarter. That's serious progress on an important front.

The company has several ways to capitalize on the shift to mobile, including its Facebook app, Messenger app, Instagram service, and text-messaging service WhatsApp, the last of which it has yet to monetize.

Facebook is also making progress in Internet video, another key area of growth, where it can take share from Google's YouTube platform. Video is comprising a bigger share of consumer Internet traffic. Internet video made up 64% of global consumer Internet traffic in 2014, according to Cisco. It expects that number to rise to 80% by 2019.

One more reason to be optimistic: Facebook is still in the very early stages of courting local advertisers, smaller businesses that may have a budget only to run an ad in a local newspaper or on a radio station, if even that. Because Facebook has the ability to so effectively target ads based on all the information the company has collected on its users, the social network is in a strong position to take market share there.

But that's not the whole story
If that doesn't sound good enough, Facebook has also developed a track record of beating expectations. April marked the 12th consecutive time Facebook beat analyst estimates on the earnings side, which means it's been exceeding the forecast numbers pretty much since it went public. Last June, earnings beat the consensus estimate by more than 30%.

So with the company heading in the right direction on the mobile, video, and local ad fronts, and a solid history of beating the forecast, investors may be tempted to buy ahead of the July 29 earnings announcement in anticipation of catching a nice gain.

There are a few reasons you might want to think twice about pulling the trigger before earnings, however.

The first is that Facebook's stock has already been driven higher in anticipation of a big quarter. The stock was trading at just about $80 on June 10, which means it's run up more than 18% in less than six weeks. That came at a time when the S&P remained largely flat, posting a gain of just about a quarter of a percent.

A strong run-up like that isn't necessarily a signal that you shouldn't buy. But you should proceed with caution.

FB Chart

FB data by YCharts

Cautionary tale
Buying before earnings can be a risky move, and we can never be sure what numbers the big money is going to react to. Look no further than Apple's most recent quarter to see how maddening the market reaction to a set of strong numbers can be.

In Apple's case, revenue was up 33%, ahead of analyst expectations. Earnings per share were up 45%, better than some expected but slightly trailing the most optimistic predictions. Based on those numbers alone, investors probably would have expected to see a nice bounce for the iPhone maker in the after hours.

But that's not what they got. Instead, Apple's shares dropped by as much as 7%. The reason appeared to be slower-than-expected iPhone sales. That's right: Sales overall were up more than expected, but sales of one important product fell short. The result: $50 billion in market cap gone in a flash.

Never too late
Apple is a stock that sells at a pretty conservative valuation, with shares trading hands at around 15 times earnings. With Facebook selling at a premium of nearly 100 times earnings, a misstep could be huge.

Is Facebook a buy? Long term, absolutely, and I'll be adding to my shares along the way. But whether it's a buy before earnings depends on an investor's risk tolerance. If you want to take the chance, make sure you have the stomach for it.

Investors are often worried that if they don't buy before a bounce, they will have missed their chance to buy. But as we've seen with many great companies -- Apple, Amazon.com, Netflix, and Priceline, to just name a few -- it's never too late to buy. You may miss out on an initial earnings bounce, but great companies will keep winning over time.