optimize js code to create sharing urls.