您当前的位置: 首页 >  Python

彭世瑜

暂无认证

  • 0浏览

    0关注

    2791博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Python:jsmin压缩js代码

彭世瑜 发布时间:2021-04-14 10:43:15 ,浏览量:0

PyPI: https://pypi.org/project/jsmin/ Github: https://github.com/tikitu/jsmin

安装
pip install jsmin
使用示例

myfile.js

function foo() {
    console.log('hi')
}

1、命令行中使用

$ python -m jsmin myfile.js

function foo(){console.log('hi')}

2、代码中使用

# -*- coding: utf-8 -*-
from jsmin import jsmin

with open('myfile.js') as js_file:
    minified = jsmin(js_file.read())
    print(minified)
    
# function foo(){console.log('hi')}    
关注
打赏
1665367115
查看更多评论
立即登录/注册

微信扫码登录

0.0552s