Why:
* There's no point fetching CleanCSS until files are about to be
optimized.
* It currently uses a fixed version of CleanCSS but we'll pass
version to initializer once more versions are supported.
function fileDraggedIn(event) {
event.preventDefault()
event.dataTransfer.dropEffect = 'copy'
+
+ Optimizer.initialize()
}
function fileDraggedOver(event) {
-onmessage = function(event) {
- if (!event.data)
- return
+var initialized = false
+onmessage = function(event) {
switch (event.data.command) {
+ case 'initialize':
+ if (!initialized) {
+ initialized = true
+ importScripts('//jakubpawlowicz.github.io/clean-css-builds/v3.4.20.js')
+ }
+ break
case 'optimize':
new CleanCSS(event.data.options).minify(event.data.input, function (error, output) {
postMessage({
}
}
-importScripts('//jakubpawlowicz.github.io/clean-css-builds/v3.4.20.js')
+
}
},
+ initialize: function() {
+ this.worker.postMessage({
+ command: 'initialize'
+ })
+ },
+
process: function (id, styles) {
this.worker.postMessage({
command: 'optimize',