Skip to content

Commit d206dbc

Browse files
author
Yoav Kadosh
committed
Added support for loading compiled CSS externally
1 parent e62fac3 commit d206dbc

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ A library for generating static stylesheets from dynamic content, to be used in
2222
* [Manually](#manually)
2323
* [Dynamic CSS Syntax](#dynamic-css-syntax)
2424
* [Enqueueing Dynamic Stylesheets](#enqueueing-dynamic-stylesheets)
25+
* [Loading the Compiled CSS as an External Stylesheet](#loading-the-compiled-css-as-an-external-stylesheet)
2526
* [Setting the Value Callback](#setting-the-value-callback)
2627

2728
## Overview
@@ -134,6 +135,18 @@ This will print the contents of `dynamic-style.css` into the document `<head>` s
134135

135136
If multiple calls to `wp_dynamic_css_enqueue()` are made with different CSS files, then their contents will be appended to the same `<style>` section in the document `<head>`.
136137

138+
### Loading the Compiled CSS as an External Stylesheet
139+
140+
Instead of printing the compiled CSS to the head of the document, you can alternatively load it as an external stylesheet by setting the second parameter to `false`:
141+
142+
```php
143+
wp_dynamic_css_enqueue('path/to/dynamic-style.css', false);
144+
```
145+
146+
This will reduce the loading time of your document since the call to the compiler will be made asynchronously as an http request. Additionally, styelsheets that are loaded externally can be cached by the browser, as opposed to stylesheets that are printed to the head.
147+
148+
The disadvantage of this approach is that the Customizer's live preview will not show the changes take effect without manually reloading the page.
149+
137150
## Setting the Value Callback
138151

139152
The example given in the overview section uses the `get_theme_mod()` function to retrieve the value of the variables:
@@ -183,6 +196,6 @@ body {
183196

184197
## TODO
185198

199+
* ~~Add support for loading the compiled CSS externally instead of printing to the document head~~ (Added in 1.0.1)
186200
* Add support for multiple value callback functions
187-
* Add support for loading the compiled CSS externally instead of printing to the document head
188201
* Add support for caching

0 commit comments

Comments
 (0)