You need to make a small change in the Gallery_View.php present in the "modules/gallery/libraries" folder.
Open the file in an editor and search for the terms "combined/css/$key" and "combined/javascript/$key". The combined CSS and javascript are served from these locations.
You need to add your CDN hostname to these paths to serve CSS and JS files from the CDN.
Here are the changes you need to make.
if ($type == "css") {
//$buf .= html::stylesheet("combined/css/$key", "screen,print,projection", true);
$buf .= html::stylesheet("https://cdn_hostname/css/$key", "screen,print,projection", true); // Enable CDN
} else {
//$buf .= html::script("combined/javascript/$key", true);
$buf .= html::script("https://cdn_hostname/javascript/$key", true); // Enable CDN
}
cdn_hostname is your CDN hostname.