-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminifier.py
More file actions
33 lines (23 loc) · 767 Bytes
/
minifier.py
File metadata and controls
33 lines (23 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import requests
import os
import json
from jsmin import jsmin
class Minify:
dir = ""
def __init__(self,folder):
self.dir = folder
def plzminify(self):
total = 0
for root, dirs, files in os.walk(self.dir):
for file in files:
if file.endswith(".js"):
path = root + "\\" + file
file = open(path,"r+",encoding="utf8")
if len(file.read()) > 0:
file.seek(0)
minified = jsmin(file.read())
file.truncate(0)
file.seek(0)
file.write(minified)
file.close()
Minify(".\cdn_static").plzminify()