1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
var initialized = false
onmessage = function(event) {
switch (event.data.command) {
case 'initialize':
if (!initialized) {
initialized = true
importScripts('//jakubpawlowicz.github.io/clean-css-builds/v4.2.2.js')
}
break
case 'optimize':
new CleanCSS(event.data.options).minify(event.data.input, function (error, output) {
postMessage({
command: 'optimized',
id: event.data.id,
error: error,
output: output,
saved: event.data.input.length - output.styles.length
})
})
}
}
|