-
AuthorPosts
-
valic Friend
valic
- Join date:
- January 2007
- Posts:
- 39
- Downloads:
- 0
- Uploads:
- 4
- Thanks:
- 2
- Thanked:
- 20 times in 2 posts
June 22, 2008 at 3:25 pm #129998If you have large css files ( from templates, components, ….), you can compress this file very good with gzip ( a dont mean just enabling gzip in joomla configuration)
Example:
My site http://www.lijepanasa.info have template_css.css which it’s 30,3 kb.
After it’s just 6kb for loading
News portal css have around 160kb, and for loading just 10kbHere we go:
1. create file template_css.php and in this file put this:
<?php
ob_start ("ob_gzhandler");
header("Content-type: text/css;charset: UTF-8");
header("Cache-Control: must-revalidate");
$offset = 60 * 60 ;
$ExpStr = "Expires: " .
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);
?>
<?php include ('template_css.css'); ?>
Last line it’s your name of css files for template (<?php include (‘template_css.css’); ?>)2.Then you put this file (template_css.php) in directory where are included css file, in this case, css folder of your template.
3. Open your index.php file of your template, and just replace line:
<link rel="stylesheet" href="<?php echo $tmpTools->templateurl(); ?>/css/template_css.css" type="text/css" />
with this:
<link rel="stylesheet" href="<?php echo $tmpTools->templateurl(); ?>/css/template_css.php" type="text/css" />
That works with any component, per example news portal:
I have created file news_css.php:<?php
ob_start ("ob_gzhandler");
header("Content-type: text/css;charset: UTF-8");
header("Cache-Control: must-revalidate");
$offset = 60 * 60 ;
$ExpStr = "Expires: " .
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);
?>
<?php include ('news.css'); ?>
and i have put this file in /public_html/components/com_news_portal/and then i just in news_portal.html.php in line 661 instead this:
@import url('.$mosConfig_live_site.'/components/com_news_portal/news.css);
i put this:
@import url('.$mosConfig_live_site.'/components/com_news_portal/news_css.php );
Enyoy 🙂-
3 users say Thank You to valic for this useful post
kashxo Friendkashxo
- Join date:
- April 2007
- Posts:
- 605
- Downloads:
- 0
- Uploads:
- 21
- Thanks:
- 11
- Thanked:
- 78 times in 40 posts
June 23, 2008 at 5:19 am #255383Thank you valic,
Very nice Tutorials. 🙂instantinlaw Friendinstantinlaw
- Join date:
- February 2007
- Posts:
- 1646
- Downloads:
- 6
- Uploads:
- 28
- Thanks:
- 68
- Thanked:
- 210 times in 62 posts
July 27, 2008 at 11:37 am #262554Another great tutorial valic.
Thanks!April 16, 2013 at 9:45 pm #490088Ok, but if i use joomla gzip should i alos use the template css and js compression?
AuthorPostsViewing 4 posts - 1 through 4 (of 4 total)This topic contains 4 replies, has 4 voices, and was last updated by tobefg 11 years, 8 months ago.
We moved to new unified forum. Please post all new support queries in our New Forum
Gzip compression for css files ( not joomla default gzip)
Viewing 4 posts - 1 through 4 (of 4 total)