Facebook is attracting advertising dollars to where its users are — on mobile devices.

The world's largest online social network surpassed expectations on all fronts in the second quarter. It grew not just profit and revenue, but also its already-massive user base and mobile advertising, as well as usage of its "family" of non-Facebook apps like Instagram, Messenger and WhatsApp.

Even so, its stock price slid after the quarterly results came out, as expenses soared 82 percent and cut into earnings. Some investors may have been waiting for even better results, or looking to cash in profits with Facebook's shares trading near record highs.

Facebook said Wednesday that it had 1.31 billion people visiting from a mobile device at least once a month, on average, during the quarter. That was up 23 percent from a year earlier.

Facebook had 1.49 billion monthly users overall, up 13 percent. It also had 968 million daily active users overall and 844 million on mobile devices.

"Once again Facebook has proven its ability to attract and retain users," said Forrester Research analyst Nate Elliott. "It's particularly impressive that users are more engaged than ever before - that the percentage of monthly users who visit every day continues to grow."

That's in contrast to Twitter, which continues to worry investors with stalling user growth and on Wednesday saw its stock price drop to its lowest level in more than a year.

Facebook's mobile advertising represented 76 percent of the total advertising revenue during the second quarter, proof that the company continues to attract advertisers to where its users are — on smartphones and other hand-held gadgets. That's up from 62 percent a year earlier.

While still far behind No. 1 Google Inc., Facebook has been steadily growing its share of the worldwide digital advertising market. Its share was 7.9 percent in 2014, up from 5.8 percent a year earlier, according to research firm eMarketer. By the end of this year, eMarketer expects Facebook's share to surpass 9 percent of the $171 billion market. Google, meanwhile, is expected to hold on to its top post with about 31 percent of the market, down slightly from last year.

In all, Menlo Park, California-based Facebook Inc.'s second-quarter net income was $715 million, or 25 cents per share. That's down from $788 million, or 30 cents per share, a year earlier.

Excluding special expenses such as stock compensation costs, Facebook earned 50 cents per share in the latest quarter, surpassing analysts' expectations of 47 cents, as polled by Zacks Investment Research.

Expenses rose 82 percent to $2.77 billion from $1.52 billion. Facebook said costs related to last year's $19 billion WhatsApp acquisition, as well as hiring new employees, contributed to the quarter's higher spending.

Facebook ended the quarter with 10,955 employees, up 52 percent form a year earlier. The majority of new hires were in research and development, as the 11-year-old company continues to set its sights on the next decade and beyond.

Revenue jumped 39 percent to $4.04 billion from $2.91 billion, squeaking past analysts' expectations of $3.99 billion.

Facebook's shares fell $3.24, or 3.3 percent, to $93.75 in after-hours trading. The stock had closed up $1.70 at $96.99, up more than 24 percent for the year.