I am relatively new to web development. If you are creating a front-end JS application, is it always the case that a page refresh incurs a new JavaScript program? Is it possible to keep the same JavaScript runtime going during a page reload? I know there are many solutions to persist the data on the front-end before/during/after page reloads...but what about the entire front-end program? I know single-page-applications are a solution to this, but I am specifically curious about maintaining the same JavaScript runtime after a page reload/refresh.
It seems that with HTML5 apps like Chrome Apps or Cordova apps, this is doesn't require page refreshes because they are not used in a browser. That being said, why isn't it possible to disable page refreshes or find a way to not have to reload a front-end JS program when someone visits your website and (accidentally) refreshes the page etc?
Yeah, every refresh starts you with a new js environment. Browsers are pretty fast, it usually takes longer downloading the application scripts than running js code. Save data somewhere and cache your scripts, it will feel snappy.
Some helpful things to learn about:
beforeunload
,unload
, andclose
window events