Any way to use Minify with external (CDN-hosted) stylesheets and scripts?
I'm hoping to use http://code.google.com/p/minify/ - Minify - and it looks really good. However I can't seem to fathom a way to get it to accept external stylesheets and JS script files, especially with the Builder.
I am hosting files on Amazon S3 but have set up a CNAME record on my domain so they are access开发者_StackOverflow中文版ible from cdn.mydomain.com
- is there really no way to do it with Minify?
Jack
Don't bother... Minify is useful for CMS systems that have conditional inclusion of multiple CSS files, and are used by people who have no clue about CSS yet alone CDNs or any other TLA... But if your working with a single site, or even a series of sites, it's not worth it. It's easy enough to do without...
You could do one of two things. Either religiously update a compressed version of all the CSS files each time you update your production site, or write a build script to do that for you (you can call it on pre-commit if you want)...
Besides, if you have the traffic levels where you need a CDN, you don't want the overhead of loading PHP for every single css or js request (even if it is just pulling from cache). Do it either manually, or programmaticly in a build script and be done with it...
Old topic but I think the contribution can help other folks :Minify : CustomSource
Example: Content from a URL
Here we want to fetch javascript from a URL. We don't know when it will change, so we use a stepping expression to re-fetch it every midnight:
if (! function_exists('src1_fetch')) {
function src1_fetch() {
return file_get_contents('http://example.org/javascript.php');
}
}
$src1 = new Minify_Source(array(
'id' => 'source1',
'getContentFunc' => 'src1_fetch',
'contentType' => Minify::TYPE_JS,
'lastModified' => ($_SERVER['REQUEST_TIME'] - $_SERVER['REQUEST_TIME'] % 86400),
));
精彩评论