File: optimizer-worker.js

package info (click to toggle)
node-clean-css 4.2.3%2B~4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,992 kB
  • sloc: javascript: 40,423; makefile: 7; sh: 6
file content (24 lines) | stat: -rw-r--r-- 599 bytes parent folder | download
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
        })
      })
  }
}