Smarty plugin that Improves CSS embedding with front-end performance in mind
Switch branches/tags
Nothing to show
Clone or download
Failed to load latest commit information. Update Nov 9, 2011
function.cssembed.php Added "force_embed" and "scoped" boolean parameters Apr 19, 2012

Smarty plugin cssEmbed

A simple smarty plugin to improve front-end performance by embedding in-page CSS rather than in an external file when the file is too small.


{cssEmbed media="screen" href="/css/main.css" threshold="15000"}

The media parameter is optional, and is a simple mapping of the <link> media attribute. So you can specify any media query in here. The threshold is also optional, with a default value of 10000. If the file weights less than "threshold" bytes, then it will be embedded in-page. If it weights more, the file is left external.

Particularly efficient when used along with assetic-smarty


You may encounter problems with relative paths in url() statements, if your CSS files and HTML documents are not in the same directory. You should prefer absolute paths (beginin with /) when using this plugin to avoid any bad surprise.