"worker" Directive (3.0.0)

Basic Coding

The following are the "worker" directive coding rules.

cmd

Specifies the name of the "worker" directive to be executed.

Type

Scalar (String)

Value

directive nameSpecify the name of the directive. This cannot be omitted.

Example

worker:
  scripts:
  - cmd: optimize

args

Specifies options for the "worker" directive to be executed.

Type

Sequence (Mapping) or Mapping

Value

Options are different depending on the selected "worker" directive. Refer to each "worker" directive for more information.

Example

worker:
  scripts:
  - cmd: optimize
    args:
      ie11: true
      ie11_ab: true

apply

Specifies the path or the conditions to be applied to the "worker" directive.
If more than one is specified, the OR condition will be used.

Type

Sequence (String)

Value

pathSpecify the path or the conditions to be applied to the "worker" directive by regular expression.
The "worker" directive will be applied by default to all resources except for paths specified in "global_exclude" in the PST configuration file.

Example

worker:
  scripts:
  - cmd: optimize
    apply:
    - ^/wp-content

exclude

Specifies the path or conditions to be excluded from application to the "worker" directive.
If more than one is specified, the OR condition will be used.

Type

Sequence (String)

Value

pathSpecify the path or conditions to be excluded from application to the "worker" directive.
The "worker" directive will be applied by default to all resources except for paths specified in "global_exclude" in the PST configuration file.

Example

worker:
  scripts:
  - cmd: optimize
    exclude:
    - /wp-content/plugins

worker > images directive

optimize

Sets the method of resource optimization for images.

args

You can set multiple optimization methods. If you set more than one method, the condition matched first will be applied. If you do not set options, resource optimization will not take place.

Type

Sequence (Mapping)

args > formats

Specifies the format (file type) in which image resource optimization is applied. If the type is not specified, resource optimization will not take place.

Type

Sequence (String)

Value
pngOptimize images for "png" files.
jpgOptimize images for "jpg/jpeg" files.
gifOptimize images for "gif" files.
webpOutput optimized files with "WebP" file format.
jp2Output optimized files with "JPEG2000" file format.
jxrOutput optimized files with "JXR" file format.
args > resize

Specifies the maximum resolution of the image. If the height or width exceeds the specified value, the image will be scaled down to fit within the specified maximum resolution while maintaining the aspect ratio. Downsizing the image will reduce the file size. If not specified, the image will not be resized.

Type

Scalar (String)

Value
height & width (pixels)Specify the resolution of the image.
args > quality

Specify the image compression level. The lower the value, the more compressed the image and smaller the file size, but the quality of the image will be lower. If not specified, the image will not be compressed.

Type

Scalar (Numeric)

Value
image compression levelSpecify a value from 1 to 100.
args > strip

Removes meta data and comments in the image. By stripping off this data (not directly related to the image), the image file size will be reduced. If not specified, the image will not be compressed.

Type

Scalar (Boolean)

Value
trueRemove meta data and comments.
falseKeep meta data and comments.
args > gif_lossy

Specifies the acceptable amount of compression artifacts when compressing GIF images. If you set a larger value, the image file will be smaller in size. However, compression artifacts will increase. If not specified, the image will not be compressed.

Type

Scalar (Numeric)

Value
compression artifactSpecify a value from 30 to 200.
args > webp_lossy

Specifies the image compression level for WebP. The lower the value, the more compressed the image and smaller the file size, but the quality of the image will be lower. If not specified, the image will not be compressed.

Type

Scalar (Numeric)

Value
image compression levelSpecify a value from 1 to 100.

Example

worker:
  images:
  - cmd: optimize
    args:
      formats:
      - png
      - jpg
      - gif
      - webp
      resize: 1920x1080
      quality: 80
      strip: true
      gif_lossy: 80
      webp_lossy: 75
    apply: .
    exclude: /wp-content/uploads/2019/

worker > scripts directive

optimize

Sets the resource optimization method for scripts.

args

You can set multiple optimization methods. If you set more than one method, the condition matched first will be applied. If you do not set options, resource optimization will not take place.

Type

Sequence (Mapping)

args > ie11

Enables optimization for IE11.

Type

Scalar (Boolean)

Value
trueEnable
falseDisable
The default setting is disabled.
args > ie11_ab

When optimization for IE11 is enabled, A/B testing will run and the smaller file size will be applied.

Type

Scalar (Boolean)

Value
trueEnable
falseDisable
The default setting is disabled.

Example

worker:
  scripts:
  - cmd: optimize
    args:
      ie11: true
      ie11_ab: true
    apply: .
    exclude: /wp-content/themes/twentytwenty/

worker > stylesheets directive

optimize

Sets the resource optimization method for style sheets.

args

You can set multiple optimization methods. If you set more than one method, the condition matched first will be applied. If you do not set options, resource optimization will not take place.

Type

Sequence (Mapping)

args > ie11

Enables optimization for IE11.

Type

Scalar (Boolean)

Value
trueEnable
falseDisable
The default setting is disabled.
args > ie11_ab

When optimization for IE11 is enabled, A/B testing will run and the smaller file size will be applied.

Type

Scalar (Boolean)

Value
trueEnable
falseDisable
The default setting is disabled.

Example

worker:
  stylesheets:
  - cmd: optimize
    args:
      ie11: true
      ie11_ab: true
    apply: .
    exclude: /wp-content/themes/twentytwenty/