Clean up javascript stripping logic for readabilty.