Move javascript persistence layer to an external library