views:

35

answers:

1

Hi,

I am using the SmartOptimizer(previously named as JSmart) PHP library to improve my site performance. This library will enhance our website performance by minifying, compressing, concatenating, and caching the JS and CSS files used in our website. You can check the details of this library here.

I want to use the concatenation feature of this library, but I don't find any good example for using that feature for my website.

My CSS files are added like this:

'link rel="stylesheet" href="slider.css" type="text/css" media="screen" /'
'link href="section.css" rel="stylesheet" type="text/css" media="all" /'
'link rel="stylesheet" type="text/css" href="global.css" media="screen,projection,tv" /'

My JS files are added like:

'script src="jquery.mousewheel.js" type="text/javascript" charset="utf-8" /'
'script src="jScrollPane-1.2.3.min.js" type="text/javascript" charset="utf-8" /'
'script type="text/javascript" src="vars.js" charset="utf-8" /'
'script type="text/javascript" src="jquery.form.js" charset="utf-8" /'

I think somebody may be already using this library, can anybody provide me a good example to use the concatenation feature of this SmartOptimozer library or just guide me to concatenate my CSS and JS files using that library.

Thanks

+1  A: 

Hi Siva,

Unfortunately, concatenation feature don't work out of the box. To take advantage of this feature you need to modify your html code as follow (file names separated by comma (,)):

<script src="jquery.mousewheel.js,jScrollPane-1.2.3.min.js,vars.js,jquery.form.js" type="text/javascript" charset="utf-8" />

Note that only files placed in the same folder can be concatenated like that.

The same rule can be applied for CSS files with the same media type.

Farhadi
Thanks Farhadi, So what can I do for the CSS files of different media types? Is there any way to concatenate those kind of CSS files also in SmartOptimizer?
Siva
To concatenate CSS files with different media types you need to hard-code media type inside css files using @media rule (http://www.w3.org/TR/CSS2/media.html#at-media-rule).
Farhadi
Farhadi, concatenation feature is working fine for both CSS and JS files now. Previously I was trying with wrong path which was causiing the issue for me, anyway tahnks for your response.
Siva