If you've ever replaced an otherwise decent smartphone or laptop because its battery life has gone from terrific to can't-use-without-constantly-plugging-in, don't worry, we know your pain. But whenever a device powered by a lithium-ion battery starts to prematurely fail, the guilt trip is almost inevitable: could you have taken better care of it? Were you charging it correctly? Or did that cheap power cord from eBay damage it?

In a lithium-ion battery, the ions move between the positive and negative electrodes - a cathode and anode - giving out energy used to power your device. When the battery is connected to a charger, the ions move in the opposite direction, essentially reversing the chemical reaction. Over time, the electrodes are worn out and the battery loses capacity.

A lithium-ion battery starts degrading as soon as it's been produced, because it slightly self-discharges even in storage. That's why you want to buy a device that's left the factory as recently as possible; older batteries inevitably die sooner.

However, it's when cycling starts - namely, regular discharging and recharging - that the degradation process really kicks in. You've probably seen lots of advice regarding an optimal charging cycle. One of the most common tips is to wait until your battery is completely empty before recharging it, because otherwise it will be susceptible to the 'memory effect' - a reduction in cycle length caused by partial charging. However, this effect largely applies to nickel cadmium batteries, and isn't much of a factor in the common lithium-ion batteries we use.

So if you don't need to fully discharge your device, is there a more optimal cycle? According to Eric Limer over at Gizmodo, that's actually a pretty tricky question. But we do know that you shouldn't leave it fully charged and plugged in, and you should also avoid getting it to 100 percent.

"[I]f you're really particular about optimising your battery's life, you should try to go from around 40 percent to around 80 percent in one go, and then back down whenever possible," Limer writes. "A bunch of tiny charges throughout the day is your second best bet, and going from zero to 100 and then 100 to zero on a regular basis will put the most strain on your lithium-ion battery."

Oh, and it doesn't matter what charger you use, because off-brand ones are unlikely to do any damage.

In fact, there's another aspect you should worry about much more than imperfect charging cycles. Lithium-ion chemistry is adversely impacted by high temperatures. These batteries prefer a moderate room temperature of 16 to 22 degrees Celsius (62 to 72 degrees F), and anything above 35°C will actually speed up degradation. Overheating is a battery's worst enemy, so never, ever leave your device in the sun. If you have a spare lithium-ion battery you're not using, the optimal way to store it is at 40 percent discharge and at around 15°C. Cold isn't as damaging to lithium-ion as heat, but sticking them in the freezer isn't wise, either.

A few other practices that may shorten a battery's life are fast charging, wireless charging and frequent discharging to 0 percent. All of these put a strain on the electrode chemistry inside, and you'll be finding yourself quickly running out of juice much more often.