Your death/reload function seems to generate the world and only after overwrite the old save file.
The consequence is that the Perma-Death can be avioded by simply pressing F5 after dying. It reloads the browser and stars the game from the last save point including all items.