"lua" Directive (3.1.5)

Basic Coding

The following are the "lua" directive coding rules.

cmd

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

Type

Scalar (String)

Value

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

Example

lua:
  body_filter:
  - cmd: wp shorten url

args

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

Type

Sequence (Mapping) or Mapping

Value

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

Example

lua:
  body_filter:
  - cmd: lazy load
    args:
    - element:img
      skip: 5

apply

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

Type

Mapping

apply > path

Specifies the path to be applied to the "lua" directive.

Type

Sequence (String)

Value

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

Example

lua:
  body_filter:
  - cmd: wp shorten url
    apply:
      path: 
      - ^/archives/

apply > if

Specifies the conditions to be applied to the "lua" directive.
If this is not set, this directive will be applied by default to all resources except for paths specified in "global_exclude" in the PST configuration file.

Type

Sequence (String)

Value

is_kusanagi_pcSpecify access from a PC browser as a condition.
is_kusanagi_mobileSpecify access from a mobile browser as a condition.
is_kusanagi_tabletSpecify access from a tablet browser as a condition.

Example

lua:
  body_filter:
  - cmd: wp shorten url
    apply:
      if:
      - is_kusanagi_pc

exclude

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

Type

Mapping

exclude > path

Specifies the path to be excluded from application to the "lua" directive.

Type

Sequence (String)

Value

pathSpecify the path to be excluded from application to the "lua" 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

lua:
  body_filter:
  - cmd: wp shorten url
    exclude:
      path:
      - /wp-content/plugins

exclude > if

Specifies the conditions to be excluded from application to the "lua" directive.
If this is not set, this directive will be applied by default to all resources except for paths specified in "global_exclude" in the PST configuration file.

Type

Sequence (String)

Value

is_kusanagi_pcSpecify access from a PC browser as an exclusion condition.
is_kusanagi_mobileSpecify access from a mobile browser as an exclusion condition.
is_kusanagi_tabletSpecify access from a tablet browser as an exclusion condition.

Example

lua:
  body_filter:
  - cmd: wp shorten url
    exclude:
      if:
      - is_kusanagi_pc

lua > header_filter directive

add

Adds HTTP header elements to be output in HTTP response headers.

args

Type

Sequence (String)

Value
key: valueSpecify the HTTP header key and value as a ":" separated string. You can specify multiple HTTP header keys.

Example

lua:
  header_filter:
  - cmd: add
    args:
    - 'Page-Speed-Technology: on'

remove

HTTP header keys that match exactly in value will be removed.

args

Type

Sequence (String)

Value
key: valueSpecify the HTTP header key and value as a ":" separated string. The HTTP header keys with an exact match in value will be removed. If the value is omitted, the specified HTTP header key will be removed regardless of value. You can specify multiple HTTP header keys.

Example

lua:
  header_filter:
  - cmd: remove
    args:
    - 'link: ; rel="https://api.w.org/"'
    - 'x-pingback'

replace

Replaces HTTP header elements in HTTP response headers.

args

Type

Sequence (Mapping)

Type

Scalar (String)

Value
key: valueSpecify the HTTP header key and value as a ":" separated string. Specify the HTTP header key to be searched. Please enclose the value in single quotes ('). You can specify multiple HTTP header keys.
This cannot be omitted.

args > replacement

Type

Scalar (String)

Value
key: valueSpecify the HTTP header key and value as a ":" separated string. Specify the HTTP header key to be replaced. Please enclose the value in single quotes ('). You can specify multiple HTTP header keys.
This cannot be omitted.

Example

lua:
  header_filter:
  - cmd: replace
    args:
    - search: 'X-MyHeader: original'
      replacement: 'X-MyHeader: replaced'
    - search: 'X-old-header: original'
      replacement: 'X-new-header: replaced'

server push

Sends the specified resource via HTTP2 Push to reduce the time required to display content. Normally, the resources required to display content are not known until the HTTP response body is obtained and its contents are parsed. By specifying a resource for "server push", you can receive the resource at the same time as the HTTP response body.

args

Type

Sequence (Mapping)

args > href

Type

Scalar (String)

Value
URLSpecify the URL for the "href" attribute of the "link" element as a string.
This cannot be omitted.

args > media

Type

Scalar (String)

Value
media queriesSpecify the media query for the "media" attribute of the "link" element as a string.

Example

lua:
  header_filter:
  - cmd: server push
    args:
    - href: /wp-content/mu-plugins/pst/font/genericons-regular-webfont.ttf

Adds HTTP header elements to be output in the "Link" field of the HTTP response header.

args

Type

Sequence (Mapping)

args > rel

Type

Scalar (String)

Value
link typeSpecify the link type for the "rel" attribute of the "link" element as a string.
This cannot be omitted.

args > href

Type

Scalar (String)

Value
URLSpecify the URL for the "href" attribute of the "link" element as a string.
This cannot be omitted.

args > as

Type

Scalar (String)

Value
resource typeSpecify the resource type for the "as" attribute of the "link" element as a string.

args > type

Type

Scalar (String)

Value
content typeSpecify the content type for the "type" attribute of the "link" element as a string.

args > media

Type

Scalar (String)

Value
media queriesSpecify the media query for the "media" attribute of the "link" element as a string.

args > crossorigin

Type

Scalar (Boolean)

Value

Set Enable/Disable CORS (Cross-Origin Resource Sharing). The default setting is disabled.

trueEnable CORS.
falseDisable CORS.

Example

lua:
  header_filter:
  - cmd: add link
    args:
    - rel: preload
      href: /wp-content/themes/twentytwenty/assets/fonts/inter/Inter-italic-var.woff2
      as: font
      type: font/woff2
      crossorigin: true

server push external css

To be used in combination with "engagement delay". In "engagement delay", execute "HTTP/2 server push" for style sheets set with "type: css/cssx" and "method: server push".

args

None

Example

lua:
  header_filter:
  - cmd: server push external css

When content is delivered via a CDN, sets a cookie so that optimized content will be delivered even under the CDN environment. Specify this setting when executing PST optimization in combination with a CDN environment.

args

Type

Mapping

args > domain

Type

Scalar (String)

Value
URLSpecify the original domain.

args > external_url

Type

Scalar (String)

Value
URLSpecify the JavaScript URL that sets the cookie for the original domain.
This cannot be omitted.

args > ext

Type

Scalar (String)

Value
cookieSpecify the value to be set for the cookie.
This cannot be omitted.

Example

lua:
  header_filter:
  - cmd: set cookie for cdn
    args:
      domain: wexal.jp
      external_url: https://www.prime-strategy.co.jp/test.js?test=test

wp remove header

Restricts the handles that WordPress outputs in the head tags, thereby reducing the amount of content the browser needs to load and improving display speed. By default, this removes "trackback permissions confirmation" and the following handles.

Handle Name
pings_open
rest_output_link_header
wp_shortlink_header

args

Type

Sequence (Mapping)

args > func_to_remove

Type

Scalar (String)

Value
handleSpecify additional handles to be removed under the "template_redirect" hook.

args > header

Type

Scalar (String / Boolean)

Value
header elementsSpecify the HTTP header elements for each handle that you set in "func_to_remove". The default value is the HTTP header elements of each handle. By setting false, the HTTP header elements will not be removed.

Example

lua:
  header_filter:
  - cmd: wp remove header
    args
    - func_to_remove: pings_open
      header: x-pingback

lua > body_filter directive

When content is delivered via a CDN, sets a cookie so that optimized content will be delivered even under the CDN environment. Specify this setting when executing PST optimization in combination with a CDN environment.

args

Type

Mapping

args > external_url

Type

Scalar (String)

Value
URLSpecify the JavaScript URL that sets the cookie for the original domain.
This cannot be omitted.

args > ext

Type

Scalar (String)

Value
cookieSpecify the value to be set for the cookie.
This cannot be omitted.

Example

lua:
  body_filter:
  - cmd: set cookie for cdn
    args:
      external_url: https://www.prime-strategy.co.jp/test.js?test=test

preload

Adds a "link" element set with "preload" to the HTML <head> section.

args

Type

Sequence (Mapping)

args > href

Type

Scalar (String)

Value
URLSpecify the URL for the "href" attribute of the "link" element as a string.
This cannot be omitted.

args > media

Type

Scalar (String)

Value
media queriesSpecify the media query for the "media" attribute of the "link" element as a string.

Example

lua:
  body_filter:
  - cmd: preload
    args:
    - href: /wp-content/themes/twentytwenty/style.css
      media: all

remove js

Removes the specified external script tags, thereby reducing the amount of content the browser needs to load and improving display speed.

args

Type

Sequence (Mapping)

args > needle

Type

Scalar (String)

Value
needle (search string)Specify a needle (search string) for the script you want to remove. It can also be specified by regular expressions.
This cannot be omitted.

Example

lua:
  body_filter:
  - cmd: remove js
    args:
    - needle: wp-embed
    - needle: vk-all-in-one-expansion-unit/assets/js/all.min.js

remove inline js

Removes the inline script tags, thereby reducing the amount of content the browser needs to load and improving display speed.

args

Type

Sequence (Mapping)

args > needle

Type

Scalar (String)

Value
needle (search string)Specify a needle (search string) for the inline script you want to remove. It can also be specified by regular expressions.
This cannot be omitted.

Example

lua:
  body_filter:
  - cmd: remove inline js
    args:
    - needle: function heateorSssLoadEvent(e)

Removes the link tag primarily used to invoke external style sheets, thereby reducing the amount of content the browser needs to load and improving display speed.

args

Type

Sequence (Mapping)

args > needle

Type

Scalar (String)

Value
needle (search string)Specify a needle (search string) for the link tag you want to remove. It can also be specified by regular expressions.
This cannot be omitted.

Example

lua:
  body_filter:
  - cmd: remove inline css
    args
    - needle: .heateor_sss_horizontal_sharing 

remove inline css

Removes the specified inline style sheet tags, thereby reducing the amount of content the browser needs to load and improving display speed.

args

Type

Sequence (Mapping)

args > needle

Type

Scalar (String)

Value
needle (search string)Specify a needle (search string) for the inline style sheet you want to remove. It can also be specified by regular expressions.
This cannot be omitted.

Example

lua:
  body_filter:
  - cmd: remove inline css
    args
    - needle: .heateor_sss_horizontal_sharing 

remove meta

Removes the specified meta tags, thereby reducing the amount of content the browser needs to load and improving display speed.

args

Type

Sequence (Mapping)

args > needle

Type

Scalar (String)

Value
needle (search string)Specify a needle (search string) for the meta tag you want to remove. It can also be specified by regular expressions.
This cannot be omitted.

Example

lua:
  body_filter:
  - cmd: remove meta
    args:
    - needle: generator

insert comment

Adds comments to HTML content.

args

Type

Sequence (Mapping)

args > comment

Type

Scalar (String)

Value
commentSpecify comments. Please enclose the comments in single quotes (').
This cannot be omitted.

args > pos

Type

Scalar (String)

Value
position to addSpecify the position to add the inline script. Specify "</head>" to place it before the "</head>" tag, or "</body>" to place it before the "</body>" tag. The default value is "</head>".

Example

lua:
  body_filter:
  - cmd: insert script
    args:
    - comment: '<!-- comment -->'
      pos: </body>

insert script

Adds inline scripts. After removing handles by using the "remove js" directive etc., you can insert the minimum required scripts without editing the template.

args

Type

Sequence (Mapping)

args > script

Type

Scalar (String)

Value
scriptsSpecify the additional inline script. Please enclose the script in single quotes (').
This cannot be omitted.

args > pos

Type

Scalar (String)

Value
position to addSpecify the position to add the inline script. Specify "</head>" to place it before the "</head>" tag, or "</body>" to place it before the "</body>" tag. The default value is "</head>".

Example

lua:
  body_filter:
  - cmd: insert script
    args:
    - script: '<script type="text/javascript">var vkExOpt = {"ajax_url":"https:\/\/www.wexal.jp\/wp-admin\/admin-ajax.php"};</script>'
      pos: </body>

add css

Adds style sheets.

args

Type

Sequence (Mapping)

args > handle

Type

Scalar (String)

Value
handle nameSpecify the additional handle name of the style sheet. Use for the "id" property of the "link" tag. By default, no handle name is specified.

args > src

Type

Scalar (String)

Value
style sheet pathSpecify the path to the style sheet file.
This cannot be omitted.

args > media

Type

Scalar (String)

Value
media queriesSpecify the media for the style sheet definition. The default media is "all".

args > inline

Type

Scalar (Boolean)

Value

Specify whether the added style sheet is inserted as an inline style. The default setting is false.

trueInsert the added style sheet as an inline style.
falseThe style sheet to be inserted is not an inline style.

args > ver

Type

Scalar (Boolean)

Value

Specify whether to append the version number to the end of the query string. The default setting is false.

trueAppend the version number to the end of the query string.
falseDo not append the version number to the end of the query string.

args > pos

Type

Scalar (String)

Value
position to add Specify the position to add the inline script. Specify "<head>" to place it after the "<head>" tag, or "</head>" to place it before the "</head>" tag. The default value is "</head>".

Example

lua:
  body_filter:
  - cmd: add css
    args:
    - handle: button
      src: /_wp/so-widgets-bundle/widgets/button/css/style.css
      pos: </head>
      inline: true

add js

Adds JavaScripts.

args

Type

Sequence (Mapping)

args > sync

Type

Scalar (String)

Value
loading methodSpecify how to load the added script. Specify "async", if you want to load the added script asynchronously and run it asynchronously. Specify "defer", if you want to load the added script asynchronously and run it synchronously after HTML parsing is complete. If other options are specified or omitted, the script will be loaded synchronously and run synchronously.

args > src

Type

Scalar (String)

Value
script pathSpecify the path of the added script.
This cannot be omitted.

args > inline

Type

Scalar (Boolean)

Value

Specify whether the added script is inserted as an inline style. The default setting is false.

trueInsert the added script as an inline style.
falseThe inline script to be inserted is not an inline style.

args > ver

Type

Scalar (Boolean)

Value

Specify whether to append the version number to the end of the query string. The default setting is false.

trueAppend the version number to the end of the query string.
falseDo not append the version number to the end of the query string.

args > pos

Type

Scalar (String)

Value
position to add Specify the position to add the inline script. Specify "<head>" to place it after the "<head>" tag, or "</head>" to place it before the "</head>" tag. The default value is "</head>".

Example

lua:
  body_filter:
  - cmd: add js
    args:
    - sync: defer
      src: /wp-content/mu-plugins/pst/js/example.js
      pos: </head>
      inline: true

defer external js

By deferring the execution of external scripts until after the completion of HTML parsing of the HTTP response body, the display speed will be shortened. Content will be displayed after HTML parsing is complete (DOMContentLoaded) and loading of style sheets, images, etc. is complete (load). Normally, scripts are executed as soon as they are found by HTML parsing, and HTML parsing will not restart until script execution is complete. This directive allows HTML parsing to be completed first, so that external scripts can be executed in parallel with the loading of style sheets and images.

args

Type

Mapping

args > apply_script

Type

Scalar (String)

Value
script pathSpecify the path of the applied script. It can also be specified by regular expressions. The default path is ".".

args > exclude_script

Type

Scalar (String)

Value
script pathSpecify the path of the script to be excluded. It can also be specified by regular expressions. The default value is false.

Example

lua:
  body_filter:
  - cmd: defer external js
    args:
      apply_script: js

replace

Replaces strings in the response body sent from the web server to the client.

args

Type

Sequence (Mapping)

Type

Scalar (String)

Value
source stringSpecify the source string.

args > replacement

Type

Scalar (String)

Value
replacement stringSpecify the replacement string.

args > limit

Type

Scalar (Numeric)

Value
number of replacementsSpecify the number of replacements. If omitted, all matched source strings will be replaced with the replacement string. The default is -1, which will replace all matching strings.

Example

lua:
  body_filter:
  - cmd: replace
    args:
    - search: WordPress
      replacement: PressWord
      limit: 1
    - search: Old Company Name
      replacement: New Company Name

replace anything

Replaces strings using regular expressions in the response body sent from the web server to the client. In the replacement string, you can include back references ($1, $2, etc.).

args

Type

Sequence (Mapping)

args > pattern

Type

Scalar (String)

Value
regular expressionsSpecify the source string by regular expressions.

args > replacement

Type

Scalar (String)

Value
replacement stringSpecify the replacement string. You can include back references ($1, $2, etc.).

args > limit

Type

Scalar (Numeric)

Value
number of replacementsSpecify the number of replacements. If omitted, all matched source strings will be replaced with the replacement string. The default is -1, which will replace all matching strings.

args > modifier

Type

Scalar (String)

Value
PCRESpecify a PCRE (Perl compatible regular expression) pattern qualifier. By default, no pattern qualifier is specified.

Example

lua:
  body_filter:
  - cmd: replace anything
    args:
     - pattern: <(/?[^<>\s]+)(\s[^<>/]+)?(\s/)?>
       replacement: <$1$2$3>
       limit: 1

lazy youtube

Delays execution of YouTube video scripts embedded in content in order to reduce the time it takes to display content. Lazy execution of embedded YouTube videos will be displayed as thumbnails in the content, and the videos will load when the thumbnails are clicked.

args

Type

Mapping

args > mobile

Type

Scalar (String)

Value
resolution (mobile)Specify the thumbnail resolution for mobile display. The following values can be specified.
maxres: 1920x1080
sd: 640x480
hq: 480x360
mq: 320x180
'': 120x90

Some videos may not have thumbnails of all sizes. The default value is "maxres".

args > pc

Type

Scalar (String)

Value
resolution (PC)Specify the thumbnail resolution for PC display. The following values can be specified.
maxres: 1920x1080
sd: 640x480
hq: 480x360
mq: 320x180
'': 120x90

Some videos may not have thumbnails of all sizes. The default value is "maxres".

Example

lua:
  body_filter:
  - cmd: lazy youtube
    args:
      mobile: mq
      pc: mq

proxy

Enables PST optimization for external resources (img, css, js) by proxying them locally.

args

Type

Sequence (Mapping)

args > proxy-host

Type

Scalar (String)

Value
URLSpecify the host name that you want to proxy.
This cannot be omitted.

args > target

Type

Scalar (Array)

Value
arraySpecify the number and types of external resources you want to proxy as a set of arrays.

args > target > element

Type

Scalar (String)

Value
resource typeSpecify the external resources you want to proxy. Specify the type "img", "css", "js", or "bg". The default value is "all" types.

args > target > limit

Type

Scalar (Numeric)

Value
number of proxiesProxy the first "n" elements specified by element. If -1 is specified, PST will proxy all. The default value is -1.

Example

lua:
  body_filter:
  - cmd: proxy
    args:
    - proxy-host: b.st-hatena.com
      target:
      - element: img
        limit: 10
      - element: css
        limit: 0
      - element: js
        limit: 0

engagement delay

Delays the closure of scripts included in the content, as well as the execution of scripts and loading of style sheets, depending on the visitor's engagement with the site.

By delaying the rendering for low engagement (e.g., the first visit), the FCP (First Contentful Paint) score will be faster. This will create the good impression of a site with a "fast-response” and improved user experience.

On the other hand, if the engagement is high (frequent visitors with many page views), PST will gradually reduce the delay execution and make it closer to immediate execution. The user experience score for response time will be lower, but the site operator will be able to provide the intended experience.

By using this directive, you can have a balance between the user experience and the quality that the site operator wants to provide, in terms of user engagement to the site.

args

Type

Mapping

args > score

Type

Scalar (Numeric)

Value
target scoreSpecify the target engagement score. The default score is 250.

The engagement score increases by approximately 100 points each time a user views the site. The score also increases with page operations (refer to "pscore" below). As the user's engagement score approaches this target value, the latency to begin loading shortens. Also, when this value goes higher, PST will not delay execution, but will proceed immediately.

args > pscore

Type

Scalar (Numeric)

Value
target scoreSpecify a per-session target engagement score. The default score is 10.

Even if the previous target engagement (score) is not exceeded, if the per-session target engagement score is exceeded by a page operation, the page will start loading at that point, ignoring the waiting time. The score will be increased by "mouse hover" events and "scroll" events on PCs, and by "tap" and "scroll" events on mobile devices. In addition, points will be added to the engagement score for each page operation.

args > high

Type

Scalar (String)

Value
event nameSpecify the event name that starts loading when user engagement is high. The default event is "DOMContentLoaded".

args > low

Type

Scalar (String)

Value
event nameSpecify the event name that starts loading when user engagement is low. The default event is "load".

Loading will start when the waiting time (delay) described below elapses from the specified timing.

args > delay

Type

Scalar (Numeric)

Value
waiting time (milliseconds)Specify the time unit to wait for loading to start. The default waiting time is 1000 ms.

The actual waiting time is the specified unit of waiting time multiplied by the ratio described below (ratio), and again multiplied by the ratio of the current engagement score to the target engagement score.

args > ratio

Type

Scalar (Numeric)

Value
percentage of change to the waiting timeSpecify the percentage of change to the waiting time to start loading when viewed on a mobile device. The default ratio is 4.

When user engagement is at its lowest, if delay is 1000 and ratio is 4, the waiting time will be 1 second for PC browsing and 4 seconds for mobile browsing.

args > max-age

Type

Scalar (Numeric)

Value
expiration time (seconds)Specify the expiration time for the user engagement score. The default value is 777600 seconds (9 days).

Until this period has elapsed since the user's last visit on the site, the last recorded engagement score will be used. According to the score, the waiting time to start loading will be shortened. If the user visits the site again after the expiration date, the engagement score will be back to the initial value. Therefore, the waiting time to start loading will be the same as the first visit.

args > inline

Type

Scalar (Boolean)

Value

Specify whether the script for "engagement delay" is inserted as an inline style, or loaded as an external script. The default setting is false.

trueInsert the script as an inline style.
falseLoad the script as an external script.

args > debug

Type

Scalar (Boolean)

Value

Enable or disable debug output. If enabled, debugged contents will be output to the browser console. The default setting is false.

true Enable debug output.
false Disable debug output.

args > scripts

Type

Sequence (Mapping)

Value
array and mappingSpecify closures, scripts, and style sheets for lazy execution. See the following for details on each node.

The loading order for scripts
Start loading in the order of the following groups, in the order listed in the scripts.
1. with "x" in type, and "async" in sync.
2. with "x" in type, and "sync" in sync.
3. without "x" in type, and "async" in sync.
4. without "x" in type, and "sync" in sync.

args > scripts > name

Type

Scalar (String)

Value
resource nameSpecify the closure/script/style sheet name. This closure/script/style sheet name must be unique. If omitted, the name will be generated automatically.

args > scripts > type

Type

Scalar (String)

Value
resource typeSpecify the resource type.
closure: Specify this for closure. You need to set a pattern.
inline js: Specify this for inline scripts. You need to set a needle.
css: Specify this for external style sheets. You need to set a path.
js: Specify this for external scripts. You need to set a path.
If you want the type to be executed first, add an "x" at the end of each resource type. (e.g., jsx)

args > scripts > needle

Type

Scalar (String)

Value
regular expressionsSpecify a regular expression to match inline scripts.
Required when the type is inline scripts (type: inline js / inline jsx).

args > scripts > before

Type

Scalar (String)

Value
scriptsOf the inline js to be delayed, extract and specify scripts that are necessary and cannot be delayed even in content, such as variable and constant definitions. There is no default value.
Can be set when the type is inline scripts (type: inline js / inline jsx).

args > scripts > pattern

Type

Scalar (String)

Value
regular expressionsSpecify a regular expression to match closure.
Required when the type is closure (type: closure / closurex).

args > scripts > args

Type

Scalar (String)

Value
argumentsSpecify the arguments to be passed to closure as a comma-separated string. There is no default value.
Can be set when the type is closure (type: closure / closurex).

args > script > cmd

Type

Sequence (Mapping)

Value
functionsSpecify a function to be executed concurrently with closure. There is no default value.
Can be set when the type is closure (type: closure / closurex).

function: Specify a function name. (e.g. function: function_name1 )
args: Specify arguments to be passed to the function as a comma-separated string. (e.g. args: 'arg1', 'arg2', 'arg3')

args > scripts > path

Type

Scalar (String)

Value
URLSpecify the path to the style sheet/script. If shortened URLs ("shorten url") are enabled prior to this directive, please specify the path accordingly.
Required when the type is external style sheets or scripts (type: css / cssx, js / jsx).

args > scripts > query

Type

Scalar (String)

Value
running methodIf the style sheet/script path contains version numbers or other query strings, specify how to run them. Specify "auto" to run them automatically. If not specified, no query string will be added. The default value is "auto".
Can be set when the type is external style sheets or scripts (type: css / cssx, js / jsx).

args > scripts > original

Type

Scalar (String)

Value
URLSpecify the absolute URL of the original style sheet. Specify the absolute URL of the original style sheet if the style sheet includes "webfont". Strategic AI "David" will generate "config" taking "webfont" into account. You can configure this value manually.
Can be set when the type is external style sheets or scripts (type: css / cssx, js / jsx).

args > scripts > method

Type

Scalar (String)

Value
URLSpecify if the style sheet includes "webfont". Strategic AI "David" will generate "config" taking "webfont" into account. You can configure this value manually.
Can be set when the type is external style sheets (type: css / cssx).

args > script > inline

Type

Scalar (Boolean)

Value

Specify whether the content of the script tag needs/does not need to be described. The default value is false.
Can be set when the type is external scripts (type: js / jsx).

trueDescribe the content of the script tag.
falseDo not describe the content of the script tag.

args > scripts > attr

Type

Sequence (Mapping)

Value
key: valueSpecify the key and value of the attribute specified in the script tag (e.g., key: id, value: my_id). There is no default key and value.
Can be set when the type is external scripts (type: js / jsx).

args > scripts > sync

Type

Scalar (String)

Value
execution methodSpecify the execution method for the closure/script/style sheet. If the closure has dependencies in the order of execution, such as a closure depending on an external script jQuery, you can specify that the scripts will be loaded sequentially. If you want to execute the closure sequentially, specify "sync" as a value to a series of closures or external scripts, and list them in order. If sequential execution is not required, specify "async" as a value. The default value is "sync".

args > scripts > comment

Type

Scalar (String)

Value
commentDescribe comment.
If you add a comment in a script, the script will be disabled. (The script will be a comment, not a script.)

args > scripts > apply

Specify the conditions to apply to the delayed script. Specify the same format as the common "lua" directive "apply".

args > scripts > exclude

Specify the conditions not to be applied to the delayed script. Specify the same format as the common "lua" directive "exclude".

Example

lua:
  body_filter:
  - cmd: engagement delay
    args:
      score: 180
      pscore: 10
      high: body
      low: load
      delay: 1000
      ratio: 5
      max-age: 3600
      inline: true
      scripts:
      - name: fa
        type: css
        path: /_wt/lightning/inc/font-awesome/versions/5.6.0/css/all.min.css
        query: auto
      - name: jq
        type: jsx
        path: /_wi/js/jquery/jquery.js
        query: auto
        sync: sync
      - name: jm
        type: jsx
        path: /_wi/js/jquery/jquery-migrate.min.js
        query: auto
        sync: sync
      - name: lm
        type: js
        path: /_wt/lightning/assets/js/lightning.min.js
        query: auto
        sync: async

lazy load

Delay the loading of images included in the content. Note that "img/iframe" in script elements are not in scope for "lazy load". After PST 3.1.5, "picture/background-image" is no longer in scope for "lazy load".

args

Type

Sequence (Mapping)

args > element

Type

Scalar (String)

Value
tag element nameSpecify the tag element that you want to Enable/Disable for "lazy load". Specify "img/iframe".
After PST 3.1.5., "picture/style" can no longer be specified.

args > disable

Type

Scalar (Boolean)

Value

Enable/Disable "lazy load" for the element specified by "args > element". The default value is false.

trueDisable "lazy load".
falseEnable "lazy load".

args > skip

Type

Scalar (String)

Value
skip numberDisable "lazy load" for the first "n" elements specified by "args > element". The default value is 0 (all enabled).

Example

lua:
  body_filter:
  - cmd: lazy load
    args:
    - element: img
      skip: 3
    - element: iframe
      disable: true

wp shorten url

Shortens URLs by replacing standard WordPress paths with shortened paths. WordPress outputs absolute URLs starting from protocol, but replacing the URLs with shortened paths reduces the amount of content the browser needs to load and improves display speed. URL shortening is processed dynamically in PST, therefore you do not need to rewrite the standard paths of WordPress themes and plugins. Shorten URLs by replacing the paths as follows.

Normal Path Shortened Path
/wp-content/uploads/_wu
/wp-content/themes/_wt
/wp-content/plugins/_wp
/wp-includes/_wi

args

None

Example

lua:
  body_filter:
  - cmd: wp shorten url

wp remove emoji

Restricts the style sheets and scripts for emojis output by WordPress, thereby reducing the amount of content the browser needs to load and improving display speed. By default, PST will remove the style sheets and scripts for emoji output by the following actions.

args

None

Example

lua:
  body_filter:
  - cmd: wp remove emoji

wp opt genericons

Optimizes the icon font Genericons loaded by WordPress. Displays alternative fonts so that content will be displayed while the fonts load in the browser.

args

None

Example

lua:
  body_filter:
  - cmd: wp opt genericons

wp remove meta

Restricts the meta tags that WordPress outputs, thereby reducing the amount of content the browser needs to load and improving display speed. By default, this removes the following handles.

Handle Name
feed_links
feed_links_extra
rsd_link
wlwmanifest_link
adjacent_posts_rel_link_wp_head
rest_output_link_wp_head
wp_oembed_add_discovery_links
wp_oembed_add_host_js
wp_shortlink_wp_head
rel_canonical
wp_generator

args

Type

Sequence (Mapping)

args > func_to_remove

Type

Scalar (String)

Value
handleSpecify additional handles to be removed.

args > meta

Type

Scalar (String / Boolean)

Value
needle (search string)Specify a needle (search string) for the meta tag to be output by the handle specified by "func_to_remove". By setting false, the meta tag will not be removed.

Example

lua:
  body_filter:
  - cmd: wp remove meta
    args
    - func_to_remove: generator
      meta: 'name="generator"'

wp remove wpcf7

Optimizes the scripts and style sheets for "Contact Form 7", a WordPress Form plug-in. When Contact Form 7 is enabled in WordPress, the scripts and style sheets are loaded even on pages with no forms. By enabling this directive, the loading of Contact Form 7 scripts and style sheets, is restricted, thereby reducing the amount of content the browser needs to load and improving display speed. Note, these scripts and style sheets are necessary for pages with forms. Therefore, please exclude pages with forms by specifying them with "exclude".

args

None

Example

lua:
  body_filter:
  - cmd: wp remove wpcf7
    exclude:
      if:
        is_page: contactus

deduplicate script

If the exact same script is loaded multiple times, keeps only one script and removes the rest. (The previous version was "reduce script").

args

Type

Sequence (Mapping)

args > apply_script

Type

Scalar (String)

Value
script pathSpecify the path of the applied script. It can also be specified by regular expressions. The default path is ".".
This cannot be omitted.

args > exclude_script

Type

Scalar (String)

Value
script pathSpecify the path of the script to be excluded. It can also be specified by regular expressions. The default value is false.

Example

lua:
  body_filter:
  - cmd: deduplicate script
    args:
      apply_script: jquery

lazy video

When the video tag is loaded, specifies "none" for the "preload" attribute in order to delay loading.

args

None

Example

lua:
  body_filter:
  - cmd: lazy video

normalize newlines

Converts Windows line feed code "CR+LF" and Mac line feed code "CR" to "LF" to normalize line feed code.

args

None

Example

lua:
  body_filter:
  - cmd: normalize newlines

tidy

If a required tag is missing on the HTML coding, PST will insert the tag. Note that the "tidy" directive is available only for the "php7/php-fpm" back-end. This will be disabled for "hhvm".

args

None

Example

lua:
  body_filter:
  - cmd: tidy

split inline css webfont

Groups together inline style sheets and converts them to external style sheets. If "webfont" is included in the css, PST will delay loading in the same way as "split_css_webfont". Note that the expiration time (Cache-Control: max-age) of the resource is set. The default time is 2 hours.

args

None

Example

lua:
  body_filter:
  - cmd: split inline css webfont

normalize jquery

jNormalizes jQuery script specifications. (The previous version was "repair jquery".)

args

None

Example

lua:
  body_filter:
  - cmd: normalize jquery

secure target blank

Adds rel="noopener noreferrer" to target="_blank" to tags that do not have the "rel" attribute. This improves performance and addresses the target="_blank" vulnerability.

args

None

Example

lua:
  body_filter:
  - cmd: secure target blank

nanofy url

Used when the "nano" option is enabled in the initial PST configuration (init). Essentially, users can not use this on their own.

args

None

Adds links to external resources.

args

Type

Sequence (Mapping)

args > rel

Type

Scalar (String)

Value
link typeSpecify the link type for the "rel" attribute of the "link" element as a string.
This cannot be omitted.

args > id

Type

Scalar (String)

Value
element IDSpecify the element ID for the "id" attribute of the "link" element as a string.

args > href

Type

Scalar (String)

Value
URLSpecify the URL for the "href" attribute of the "link" element as a string.
This cannot be omitted.

args > as

Type

Scalar (String)

Value
resource typeSpecify the resource type for the "as" attribute of the "link" element as a string.

args > imagesrcset

Type

Scalar (String)

Value
resource valueSpecify the resource value for the "imagesrcset" attribute of the "link" element as a string.

args > imagesizes

Type

Scalar (String)

Value
resource size valueSpecify the resource size value for the "imagesizes" attribute of the "link" element as a string.

args > type

Type

Scalar (String)

Value
content typeSpecify the content type for the "type" attribute of the "link" element as a string.

args > media

Type

Scalar (String)

Value
media queriesSpecify the media query for the "media" attribute of the "link" element as a string.

args > crossorigin

Type

Scalar (Boolean)

Value

Specify Enable/Disable CORS (Cross-Origin Resource Sharing). The default setting is false.

trueEnable CORS.
falseDisable CORS.

args > pos

Type

Scalar (String)

Value
position to addSpecify the position to add the inline script. Specify "<head>" to place it after the "<head>" tag, or "</head>" to place it before the "</head>" tag. The default value is "</head>".

Example

lua:
  body_filter:
  - cmd: add link
    args:
    - rel: stylesheet
      href: /_wp/so-widgets-bundle/widgets/button/css/style.css
      pos: </head>
      as: style

Optimizes DNS name resolution for external resources by enabling the "dns-prefetch" and "preconnect" attributes of the "link" tag.

args

Type

Sequence (Mapping)

args > rel

Type

Scalar (String)

Value
link typeSpecify the link type for the "rel" attribute of the "link" element as a string.
This cannot be omitted.

args > href

Type

Scalar (String)

Value
URLSpecify the URL for the "href" attribute of the "link" element as a string.
This cannot be omitted.

args > pos

Type

Scalar (String)

Value
position to addSpecify the position to add the inline script. Specify "<head>" to place it after the "<head>" tag, or "</head>" to place it before the "</head>" tag. The default value is "</head>".

Example

lua:
  body_filter:
  - cmd: link dns prefetch
    args:
    - rel: dns prefetch
      href: https://www.google.com/
      pos: </head>

Optimizes the display of the first view by enabling LCP (Largest Contentful Paint) image "preload".

args

Type

Sequence (Mapping)

args > rel

Type

Scalar (String)

Value
link typeSpecify the link type for the "rel" attribute of the "link" element as a string.
This cannot be omitted.

args > href

Type

Scalar (String)

Value
URLSpecify the URL for the "href" attribute of the "link" element as a string.
This cannot be omitted.

args > element

Type

Scalar (String)

Value
element nameSpecify the element name for the "id" attribute of the "link" element as a string.

args > as

Type

Scalar (String)

Value
resource typeSpecify the resource type for the "as" attribute of the "link" element as a string.

args > imagesrcset

Type

Scalar (String)

Value
resource valueSpecify the resource value for the "imagesrcset" attribute of the "link" element as a string.

args > imagesizes

Type

Scalar (String)

Value
resource size valueSpecify the resource size value for the "imagesizes" attribute of the "link" element as a string.

args > pos

Type

Scalar (String)

Value
position to addSpecify the position to add the inline script. Specify "<head>" to place it after the "<head>" tag, or "</head>" to place it before the "</head>" tag. The default value is "</head>".

Example

lua:
  body_filter:
  - cmd: link lcp preload
    args:
    - rel: preload
      element: img
      href: https://www.wexal.jp/wp-content/uploads/2020/07/4a125c266368383c22b0e669d4b7894d.jpg
      as: image
      pos: </head>