def safe_dump_js(js, abspath, 
                 fastmode=False, compress=False, enable_verbose=True):
    abspath = str(abspath)
    temp_abspath = "%s.tmp" % abspath
    dump_js(js, temp_abspath, fastmode=fastmode, 
            replace=True, compress=compress, enable_verbose=enable_verbose)
    shutil.move(temp_abspath, abspath)