After page refresh jquery stops working

Answer from original poster:

So the problem was that i used $(document).ready() what i realy needed was $(window).load()


I know this is an old question I stumbled upon. Anyway, my answer might help another when the same problem arises. Unfortunately I haven't got the reputation to comment on Trott's answer above.

That being said, if you are using jQuery 1.8 or any version after his, then use $(window).on('load', function() { ... });. The $(window).load() was deprecated in jQuery version 1.8 and will throw the error jquery url.indexOf is not a function (at least in jQuery 3.4.1)