You'll often hear that it's a good thing to max out your 401(k). Not only can that shield more of your income from taxes (assuming it's a traditional 401(k) plan you're funding, as opposed to a Roth), but it can also set you up with a larger nest egg down the line.

This year, maxing out a 401(k) means contributing $23,000 to that account if you're under 50. If you're 50 or older, you get a $6,500 catch-up contribution option that raises your total to $30,500.

Your goal this year may be to max out your 401(k) plan -- especially if you've never done so before. But before you focus on that, there's another financial goal that may need your attention.

A person at a laptop.

Image source: Getty Images.

Make certain you're set for emergencies

It's definitely important to bring plenty of savings with you into retirement so you don't end up reliant on Social Security alone. But before you max out your 401(k) plan -- this year or in general -- you'll want to make sure you're set as far as your emergency fund is concerned.

The purpose of an emergency fund is to have cash to tap in a pinch, whether to fix your car's engine, replace your home's roof, or cover your general expenses during a period of unemployment. If you don't have a solid emergency fund, you could end up with a serious pile of debt on your hands when unplanned expenses strike. Debt has a pesky way of lingering and eating up income that could otherwise be put to good use.

If you rack up too much debt due to not having an emergency fund, you might make it so that in the future, you can't afford to fund a 401(k) period, let alone max it out. So before you put so much as another dollar into your 401(k), make sure your emergency fund is in a good place.

What should your emergency fund look like?

If you're not sure how much money to keep in savings for emergencies, as a general rule, the minimum total you should aim for is three months' worth of essential living expenses. But for better protection, six months' worth is optimal.

Some situations may warrant an even larger emergency fund. Let's say you have a unique role within your industry -- one that could be really hard to replace in the event that you're laid off. In that situation, it could be a wise idea to build an emergency fund to cover nine to 12 months of living costs, as it might take that long to find a replacement job.

All told, it's a very good thing to max out 401(k) plan contributions. But your emergency fund should absolutely take priority over your 401(k). If you need money in a pinch, tapping your 401(k) plan prior to age 59 1/2 could result in a costly 10% early withdrawal penalty, whereas tapping a savings account should cost you nothing. Keep that in mind before you make the decision to pump more money into your 401(k).