Buying snacks and other nonperishable items? You might want to skip the trip to the supermarket. Buying some food online can be easier on your wallet—and on you.

E-commerce retailers, such as Amazon, and manufacturers themselves are offering deals that can cost at least 10 percent less than nonperishable items purchased in stores, says Sam Gagliardi, head of e-commerce at IRI Worldwide, a market research firm headquartered in Chicago.

That's because many online retailers are focused on attracting consumers and building a loyal clientele, so they're willing to sell some products for little or no profit, he says, noting that online-only retailers can provide lower prices due to their lower overhead.

But grocery stores still offer competitive pricing, especially on perishable foods. Staples such as frozen food, milk, fish, and meat are still cheaper to buy in a store. And grocers often sell perishables at below cost to entice you into the store, where, they hope, you'll be tempted to buy higher-priced products.

Online retailers, meanwhile, have shipping costs factored into their prices or offer free shipping if you spend a certain amount.

Gagliardi recommends a hybrid strategy for your online-offline spending: Buy perishables in the store and nonperishables online.

Here's a look at which food categories to add to your online shopping list:

Snack Bars
For many supermarkets, snack bars are a huge category. That's why stores often place the bars near the front to encourage impulse buying.

But snack-bar makers themselves are offering online discounts if you agree to buy the bars from them directly at regular intervals, says Jordan Gaspar, managing partner at AccelFoods, an early-stage investment firm in food and beverage startups.

"The companies are incentivized to come up with their best offer" in order to build customer loyalty, Gaspar says.

Snacks maker Kind, for example, will cut the retail price of its snack bars by 37 percent if you sign up online to buy in bulk on a monthly, bi-monthly, or quarterly basis.

Specialty Diet Food
As shoppers purchase more specialty diet food such as gluten-free, non-GMO, and nut-free items, online prices often beat those on store shelves, says Brian Helman, president of Vitacost, a vitamin and healthy food products website owned by the Kroger Co., a supermarket chain.

"With an automated warehouse, we are able to pass some of those costs back to the consumer," says Helman. Specialty diet foods, he adds, can be especially pricey because of increased production costs and harder-to-source ingredients.

Coffee
Even as supermarkets tout coffee brands with plenty of name recognition (i.e. Starbucks), a larger assortment of smaller brands are gaining a reputation for affordable pricing online, says IRI.

Today, many established online brands, such as San Francisco Bay and Caza Trail, cost less and rarely appear on store shelves. Increased competition also tends to make online coffee cheaper than what's available in stores, says Gagliardi.

Healthy Beverages
Non-soda soft drinks are also getting a bigger online presence. Brands are using the web not only to generate sales but to educate consumers on health trends, which is harder to do in physical stores, Gaspar says. As a result, brands are more likely to offer online discounts.

"These small brands can get growth that's achievable through these e-tail channels," Gaspar says. Recently AccelFoods invested in Four Sigmatic, a company that offers hot beverages made from dissolvable mushrooms and focuses on educating consumers through online channels, she adds.

Baby Food
Buying everything from healthy teething cookies to baby formula can be expensive and time-consuming. Surprisingly, the category of baby food and supplies is one that online retailers—including Amazon—often sell at cost to entice busy parents to become loyal customers, says IRI's Gagliardi.

Buying online is 15 percent less expensive than in the store, according to the firm's research. "Amazon is trying to penetrate as many households as possible—at times selling at a loss," he says.

Pasta
For years, pasta makers sold by the single bag or box in stores, while allowing bulk sales only online or through warehouse clubs such as Costco and Sam's Club, according to IRI research.

Nows, thanks to services such as Amazon Fresh, e-commerce sites are finally unbundling large pasta packs for individual consumers and passing on the savings. The outcome is single packages of pasta that cost up to 50 percent less than in store, according to the research.

And while warehouse clubs that sell bulk pasta have a limited range of offerings, that's not so online. "Now [pasta eaters] are able to buy exactly what they want," Gagliardi says.