Minify JS data and saves to file.

    Data should be a string will whole JS content, and file will be
    overwrited if exists.

def jsMin(data, file):
    """
    Minify JS data and saves to file.

    Data should be a string will whole JS content, and file will be
    overwrited if exists.
    """
    print 'Minifying JS... ',
    url = 'http://javascript-minifier.com/raw' #POST
    req = urllib2.Request(url, urllib.urlencode({'input': data}))
    try:
        f = urllib2.urlopen(req)
        response = f.read()
        f.close()
        print 'Final: {:.1f}%'.format(100.0*len(response)/len(data))
        print 'Saving: {} ({:.2f}kB)'.format(file, len(response)/1024.0)
        _save(file, response)
    except:
        print 'Oops!! Failed :('
        return 1
    return 0