Search. Compare options. Click buy. Look out for a package on your doorstep the next day, or even that same day, without ever having to get in your car. The mail truck comes by and drops off your order with a bunch of others, probably on a route she would've been driving anyway, no extra trip needed. Totally green, right?

Well, not exactly.

In May, Amazon announced that tens of millions of items on its platform would be available not onlyfor free two-day shipping, but same-day delivery, with a Prime subscription. Other retailers have no choice but to compete: Fast lead times at no extra charge can make the difference between winning the sale or losing it.

Following Amazon's rollout, Walmart unveiled free one-day shipping without a membership fee, and Target already had a free one-day program for its loyalty cardholders. According to the research firm Rakuten Intelligence , over the past two years the time from purchase to delivery has declined from 5.2 days to 4.3 days. Amazon is faster still, at 3.2 days on average.

The problem is, there is a cost to the environment — and retailers are doing a careful dance to try to mitigate it without turning customers away.

"The time in transit has a direct relationship to the environmental impact," says Patrick Browne, director of global sustainability at UPS. "I don't think the average consumer understands the environmental impact of having something tomorrow vs. two days from now. The more time you give me, the more efficient I can be."

e-commerce can be greener than a bunch of shoppers making personal trips in their own cars: Consolidating products and delivering them on one route to a bunch of homes requires fewer miles on the road. In theory,e-commerce can be greener than a bunch of shoppers making personal trips in their own cars: Consolidating products and delivering them on one route to a bunch of homes requires fewer miles on the road. In a 2012 study , University of Washington professor Anne Goodchild found that grocery delivery can cut between 80% and 90% of carbon emissions, for example, compared to consumers going to pick up their items on their own. However, she says, that calculus changes significantly if items are coming from further away and have to be sent immediately, which creates fewer opportunities for lumping deliveries together.

"The efficiency and those benefits of delivery came from consolidation and sharing a big vehicle," Goodchild says. "And as we move away from that, if we move towards basically paying someone to make a trip for us, a lot of those benefits are eroded."

Miguel Jaller, the co-director of the Sustainable Freight Research Center at the Institute of Transportation Studies at UC Davis, found that if a delivery van makes less than about six stops on a trip, the emissions advantage disappears. (And even with more stops per trip, there still may be more nitrogen oxide involved.)

In 2017, UPS disclosed that the e-commerce boom had decreased the number of packages it dropped off per mile, leading to more trucks on the road and higher greenhouse gas emissions.

In the worst-case scenario, with one delivery per trip, the carbon emissions can be as much as 35 times greater than they would be for a fully-loaded delivery van. That doesn't happen very often, but contracted last-mile courier services — like Amazon Flex and Walmart's Spark Delivery — may be delivering only a few orders at once, often in a personal vehicle or small van. What's more, many consumers are ordering online and still making trips to the store, meaning there are just more cars on the road.

With great scale comes greater efficiency

Inefficient routes are not only more carbon-intensive — they're also more expensive for the shipper. If fast delivery is free, it's only because the retailer is subsidizing that delivery to fight for customers at a time of fierce competition and rapid growth. That means consumers aren't feeling the true cost — either environmental or financial — of getting their e-commerce goods super quickly.

"There are some companies that can absorb the cost," Jaller says. "One of them — it's one of the largest ones — has been absorbing the logistic cost for a while. And it's in the billions of dollars per year."

Jaller was referring to Amazon. For its part, Amazon says that the bigger it gets, the more efficient it can be. The news that Prime was transitioning to one-day shipping came with the announcement of an $800 million investment in logistics infrastructure, like fulfillment centers, trucks and smaller distribution hubs close to population centers.

Because of its scale, Amazon denies that it's speeding up at the environment's expense. The items eligible for same-day delivery are typically common orders, like diapers and detergent, that can be pre-positioned where consumers are most likely to need them. That cuts down on transporting things by air, which emits dramatically more carbon than ground transportation.

"Prime Free One-Day is possible because we've been building our network for over 20 years," a spokesperson said in a statement. "This allows Amazon to work smarter based on decades of process improvement and innovation, and to deliver orders faster and more efficiently."

There are a few other companies that might be able to rival that level of proximity to the customer and volume of goods, which allow them to consolidate deliveries even at a fairly rapid rate. Walmart, for one, has more than 4,700 store locations and an extensive network of warehouses from which it can deliver packages, so trucks don't have to visit multiple locations.

Some third-party logistics providers also say they are big enough to offer same or next-day service for retail clients without sacrificing carbon efficiency. XPO Logistics is among the largest, with 90 facilities across the country, and says it uses machine learning algorithms to direct where inventory should be stored.

"We look at who's buying the products from where, and who's returning products to where, and are able to forecast where to have the products strategically positioned nearby the consumer," says XPO's chief information officer Mario Harik.

is still an inexact science. Amazon itself has offered consumers a new option, called "Amazon Day," to help them consolidate their deliveries into one drop-off per week. The company also offers discounts and rewards when shoppers choose " But forecasting demandis still an inexact science. Amazon itself has offered consumers a new option, called "Amazon Day," to help them consolidate their deliveries into one drop-off per week. The company also offers discounts and rewards when shoppers choose " no-rush shipping ," which gets people their packages in six business days.

"I would not say [Amazon is] pretty environmentally friendly," Jaller said. "I would say less environmentally bad than others."

The tradeoff between speed and carbon emissions gets larger with smaller retailers that make more custom deliveries, from meal kit services to subscription razor companies — but they feel they need to match the shipping convenience of market leaders to maintain their foothold. And when things are free, people tend to consume more of them, which could raise overall emissions even further.

In general, it's very difficult to pin down the environmental impact of e-commerce, let alone how much of an effect delivery speed has on carbon emissions. It depends on the layout of each city, the gas mileage of each vehicle and logistics networks that change from week to week. Consumers might even use the time they saved while shopping online to do something else that involves driving. If Amazon delivered everything in electric vehicles, one-day shipping might be just as climate-friendly as individual trips — but in a recent big last-mile investment, Amazon ordered 20,000 conventionally-fueled delivery vans

Still, it's pretty clear that the climate would benefit if everything slowed down a little. If consumers were more aware of the impact of their ordering choices, they might think twice about asking for things as soon as possible. Especially if it's something they don't really need immediately, like a new rug.

Fortunately, behavioral economics has a lot to say about this problem.

There is an answer: Just nudge

"Nudging," or leading consumers to make the best choice on their own without seeming bossy about it, is a tactic used everywhere from health care to traffic enforcement. Utility ratepayers have been persuaded into using less power and water by invoices that tell them how much they're consuming compared to their neighbors — bringing the power of guilt and social norms to bear on decision making. Similarly, hotels invite guests to keep their towels rather than replacing them with fresh ones each day in order to conserve resources.

There is already evidence that e-commerce consumers may be able to be gently pushed toward less harmful choices. Josué Velázquez Martínez, a research scientist at MIT's Center for Transportation and Logistics, found in a test in Mexico that 52% of consumers were willing to wait longer when told at checkout that slower shipping would save trees.

Sometimes all that needs to happen is reframing the decision, by "relabeling" standard shipping as "green shipping," and making it the default option so that shoppers have to pro-actively choose the faster speed rather than the other way around.

Jenic Mantashian, executive vice president of behavioral science consulting firm BVA Nudge Unit, says you could even give people points or badges for picking the greener option that can be redeemed for discounts.

Many people want to be seen as responsible. Companies could leverage that self-consciousness and create a "virtue signal" to neighbors — put slower-shipped boxes in a different color — without having to raise prices.

"We've seen traditional economic incentives work, in terms of changing behavior," Mantashian says. "But we've also seen how your personal core values and what you're trying to achieve as a human being is super important."

If that fails, of course, retailers could also fall back to regular price-based incentives — and they might not even lose that much business. According to a survey by the consulting firm Capgemini , consumers who felt they received good service were willing to pay nearly 5% of the total order value for two-hour wait times. And that would be good for both companies and the environment.

"If they paid the true price of that delivery, they would ask themselves if they really needed it sooner," says Goodchild. "I think that the fundamental idea of really paying for what it cost in terms of traffic congestion and emissions is something we don't do right now. The more we did, the more balance there would be in what people are asking for and what people are willing to buy."

It may be true that the best things in life are free — but in this case, it's usually because the earth is paying for it down the line.

— CNN Business' John General and Richa Naik contributed reporting.