Assets Configuration

Control how CSS, JavaScript, and other assets are loaded and managed in your WordPress site.

Assets Configuration Options

The assets section in your config.yml file controls how assets are loaded and managed:

1
assets:
2
version: "1.0.0" # Version string for cache busting
3
lazyload: true # Enable image lazy loading (true, 'vanilla', or false)
4
deferred-scripts: # Scripts to defer loading
5
- 'bones-scripts'
6
- 'jquery-migrate'
7
excluded-scripts: # Scripts to exclude from loading
8
- 'wp-embed'
9
- 'comment-reply'
10
excluded-styles: # Styles to exclude from loading
11
- 'wp-block-library'
12
- 'wp-pagenavi'

Version

The version parameter adds a version string to asset URLs for cache busting. This ensures that browsers load fresh versions of your assets when you update them.

1
assets:
2
version: "1.2.3" # Will append ?ver=1.2.3 to asset URLs

Lazy Loading

The lazyload parameter controls image lazy loading. It has three possible values:

  • true: Enable native lazy loading using the loading="lazy" attribute.
  • 'vanilla': Use vanilla JavaScript lazy loading with data-src and data-srcset attributes.
  • false: Disable lazy loading.

Deferred Scripts

The deferred-scripts parameter specifies which scripts should be deferred until after the page has loaded. This can improve page load performance.

1
assets:
2
deferred-scripts:
3
- 'jquery'
4
- 'jquery-migrate'
5
- 'bones-scripts'

Excluded Scripts and Styles

The excluded-scripts and excluded-styles parameters specify which scripts and styles should be excluded from loading. This can reduce page load time by removing unnecessary assets.

1
assets:
2
excluded-scripts:
3
- 'wp-embed'
4
- 'comment-reply'
5
excluded-styles:
6
- 'wp-block-library'
7
- 'wp-pagenavi'

Best Practices

  • Use the version parameter to ensure browsers load fresh versions of your assets.
  • Enable lazy loading for images to improve page load performance.
  • Defer non-critical scripts to improve initial page load time.
  • Exclude scripts and styles that aren't needed on your site.