optimize js for video preview