optimizing and cleanup of js