Memoize variables in Javascript file