-
Notifications
You must be signed in to change notification settings - Fork 38
Advanced Usage
Q: How can I combine files out of multiple CSS- or JS-folders?
A: By setting as directory argument a comma delimited list of folders:
$booster->css_source = '../css_1,../css_2';
echo $booster->css_markup();
or an array
$booster->css_source = array('../css_1','../css_2');
echo $booster->css_markup();
The same holds true for JS:
$booster->js_source = '../js_1,../js_2';
echo $booster->js_markup();
or
$booster->js_source = array('../js_1','../js_2');
echo $booster->js_markup();
Q: I don’t want to have CSS-JS-Booster to pull all the files from inside a
directory, nor do I want to rename the files alphabetically. I rather want
full control over which files to use. Is this possible?
A: Yes. $booster->css_source
and $booster->js_source
are very flexible in
what they accept as source. You don’t need to specify a folder, you can
also specify a single file, or multiple files (either comma-separated or as
genuine array). Here are some examples:
$booster->css_source = '../css_1/reset.css,../css_1/base.css';
echo $booster->css_markup();
or as array
$booster->css_source = array('../css_1/reset.css','../css_1/base.css');
echo $booster->css_markup();
or files and folder mixed in an array:
$booster->css_source = array('../css_1/reset.css','../css_1/base.css','../css_2');
echo $booster->css_markup();
Q: I don’t want to have CSS-JS-Booster to pull files from anywhere at all.
I rather want to pass it a CSS-/Javascript-string and have that optimized.
Is this possible?
A: Yes, $booster->css_source
and $booster->js_source
can now also accept
code-strings as source. But you have to switch the respective booster-part to
stringmode before by setting $booster->css_stringmode = TRUE;
or
$booster->js_stringmode = TRUE;
. Here is an example:
$booster = new Booster();
$booster->css_stringmode = TRUE;
$booster->css_source = '.div1 {
display: block;
width: 400px;
}';
echo $booster->css();
Q: For CSS and JS tags, can I have its output-markup in HTML 4.01 fashion?
A: No problem, do this:
$booster->markuptype = 'HTML';
echo $booster->css_markup();
or
$booster->markuptype = 'HTML';
echo $booster->js_markup();
Q: Can I stop CSS-JS-Booster to cleanup the cache folder on sundays?
A: Yes, just configure this:
$booster->booster_cachedir_autocleanup = FALSE;
Q: For CSS, how can I define a different/specific target-medium?
A: By setting the desired media before echoing the markup:
$booster->css_media = 'screen,projection';
echo $booster->css_markup();
Q: For CSS, can I define a second folder to feed an alternate stylesheet?
A: Sure, e.g. like this:
$booster->css_source = 'css_1';
echo $booster->css_markup();
//
$booster->css_source = 'css_2';
$booster->css_rel = 'alternate stylesheet';
$booster->css_title = 'Alternate Stylesheet';
echo $booster->css_markup();
Q: For CSS, can I influence in how many even parts it gets split?
A: Nothing easier than this:
$booster->css_totalparts = 4;
echo $booster->css_markup();
Q: I would like to have YUI Compressor to minify my CSS locally. Is that
possible?
A: Yes, it is possible, as long as you have a dedicated server with Java
installed:
$booster->css_hosted_minifier = TRUE;
echo $booster->css_markup();
Please note that this feature is still alpha and possibly buggy!
Q: The JS-minification seems to break my scripts. Can I disable it?
A: Yes, you can:
$booster->js_minify = FALSE;
echo $booster->js_markup();
Q: The JS-minification through the Google webservice takes too long.
Can I have a local Google Closure minifier instead?
A: Yes, you can, as long as you have a dedicated server with Java installed:
$booster->js_hosted_minifier = TRUE;
echo $booster->js_markup();
Please note that this feature is still alpha and possibly buggy!
Q: I would like to make use of the async and/or defer attributes for JS.
Is there a way to enable them?
A: Yes, you can set the mode easily. Just remember that when Booster detects
any document.write inside your script, it will ommit those attributes.
This will set the async, and as fallback for older browsers defer attribute:
$booster->js_executionmode = "async";
echo $booster->js_markup();
This will set the defer attribute:
$booster->js_executionmode = "defer";
echo $booster->js_markup();
Please note: if CSS-JS-Booster detects a document.write inside JavaScript
it will omit async and defer as both conflict with document.write.
Q: I would like to make use of the onload attribute for JS (like for example
together with the async and/or defer attributes). How?
A: This will fill the onload attribute with the function “initialize();”:
$booster->js_onload = "initialize();";
echo $booster->js_markup();
Q: I need to debug CSS (e.g. in Firebug) or JS in the console – but I cannot
find anything due to dataURI-fication and minification…
A: Yes, that’s hard. In this case turn debug-mode on before outputting:
$booster->debug = TRUE;
echo $booster->css_markup();
echo $booster->js_markup();
Q: Can I have CSS with big inlined images lazyload on DOM ready?
A: Yes, just set the following parameter:
$booster->css_lazyload = TRUE;
In an ideal way you would split your image-heavy CSS apart from your normal CSS
and just load that one later:
$booster = new Booster();
$booster->css_source = 'styles_without_images.css';
echo $booster->css_markup();
$booster->css_source = 'styles_with_images.css';
$booster->css_lazyload = TRUE;
echo $booster->css_markup();