I had this exact same issue and resolved it.
I've a Netgear router downstairs and a Linksys router upstairs, and the S4 was struggling with keeping a connection with both. As this was a new device I though the issue might be hardware related, as it was showing a wifi connection but pages weren't loading, Facebook had no pics etc. Then I was in McDonalds and trying to jump on the "very strong" wifi and it was losing a connection before I could login to the wifi page.
Aaanyway, it's all down to allowing the wifi to switch off when the device is in sleep mode, to save power. I found a thread from last year where this issue plagued the S3, and the fix worked a treat for my S4:
WiFi issues disconnects etc (fixed for me)
It's been fine ever since, and no reduction in battery. Strange thing is I've just gone back into that service menu and power save is set to "On" again, yet if I go via the GUI and advanced wifi settings, swifi during sleep is set to Never. No matter, wifi's working like a dream now. o/