I'm already using a cdn here is my code
define('RVCDN', 'http://mycname.domain.com');
define('RVCDN_ROOT_URL', RVCDN . get_absolute_root_url(false));
add_event_handler('get_derivative_url', 'cdn_derivative_url', EVENT_HANDLER_PRIORITY_NEUTRAL, 4);
add_event_handler('get_combined_css', 'cdn_combined_css', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
add_event_handler('combined_script', 'cdn_combined_script', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
add_event_handler('combined_css_postfilter', 'cdn_combined_css_postfilter');
function cdn_derivative_url($url, $params, $src, $rel_url)
{
if (strpos($url, '?')===false && ($params->type==IMG_THUMB || $params->type==IMG_XXSMALL) )
{
$id = $src->id;
if ($id%10==0 || $id%10==2)
{
if ($url[0]=='/')
$url = RVCDN.$url;
else
$url = RVCDN_ROOT_URL.$rel_url;
}
}
return $url;
}
function cdn_prefilter($source, &$smarty)
{
$source = str_replace('src="{$ROOT_URL}{$themeconf.icon_dir}/', 'src="'.RVCDN_ROOT_URL.'{$themeconf.icon_dir}/', $source);
$source = str_replace('url({$'.'ROOT_URL}', 'url('.RVCDN_ROOT_URL, $source);
return $source;
}
function cdn_combined_script($url, $script)
{
if (!$script->is_remote())
$url = RVCDN_ROOT_URL.$script->path;
return $url;
}
function cdn_combined_css($url, $loc)
{
$url = RVCDN_ROOT_URL.$loc;
return $url;
}
function cdn_combined_css_postfilter($css)
{
return str_replace('url(/', 'url('.RVCDN.'/', $css);
}