How to save user's location in databaseYou're going to have to make an ajax call to a script on your server to add the data to your database. You should really try something before asking here though. Come back when you have an issue with your code ;)

How to reduce the “Time for the first byte” on my website?Outputting the head as soon as possible, can be a big performance gain. If your head contains css files or scripts (even though it shouldn't), the browser could be paralleling those downloads. If the browser has to wait to parse the document, it doesn't even know what it could be downloading.