changed javascript wrapper to cache jQuery variable