First, make sure that the HSA plan makes sense dollars wise compared to the non HSA plan. At my work the non HSA plan is much better because you have no out of pocket expenses compared to all out of pocket until you hit the $5,000 deductible with the HSA plan. That's a high price to pay in my opinion in order to save about $1,000 in taxes.
Second, if the HSA still makes sense, then I would contribute to that before maxing out your 401k. HSA is better than 401k or IRA because its tax free going in and coming out.