Better javascript snappy implementation