You should use a cookie or local storage because the lifetime of your javascript ends when you refresh the page.
$(document).ready(function() {
var firstTime = localStorage.getItem("firstTime");
if(! firstTime){
// all your current code
localStorage.setItem("firstTime", true);
}
});