Is it an Electrical or Fuel Related problem that is causing trouble with my Elantra?

I own a 2004 Elantra. The other night I noticed it took longer than usual to turn over. I figured it was the cold weather and I could take it to Advance Auto and let them check the battery the next day. I did that and they said the battery was good. It ran fine that day and the next. This morning I went to start it up and it would crank and crank but not turn over. I got out the jumper cables and finally got it to turn over- and right as it started I heard a popping sound. Not sure if it was a backfire or what. I took it back to the parts store and they re-tested it and said the battery, alternator and starter all appeared to be good. At this point I am beginning to scratch my head- Do I have a ghost that is draining the battery somehow? Could there be a bad spot on the starter? Someone else suggested a fuel injection issue or something of that nature- maybe a relay switch going bad. Any thoughts would be appreciated. Today it sat for about 7 hrs plus and it started right up this evening- Ran fine. I shut the car off and tried to start it again and it started up with no problem whatsoever.

If the engine cranks over and does not start my first guess would be crankshaft position sensor. It would be good to have a code reader plugged in at the time of the problem it may show up as a pending code.

It seems crankshaft position sensor a prone to failure on Hyundai

It has only happened one time so far- I will be vigilant about having it checked if it happens again or when I take it in for service next, which should be in the next week or two- Thanks!