I’m investigating how useful ClientScript Packages may be for an upcoming project. Example config code is as follows:
,'packages' => array( 'mypackage' => array( 'baseUrl' => '/themes/default/' ,'css' => array( 'css/screen-only.css' ,'css/print-only.css' ) ,'js' => array( 'js/script1.js' ,'js/script2.js' ) ) )
When Yii builds the web page, it creates stylesheet links for all the CSS files, but there are no "media" attributes. Some of the CSS files are for "screen", and some for "print".
<link rel="stylesheet" type="text/css" href="/themes/default/css/screen-only.css" /> <link rel="stylesheet" type="text/css" href="/themes/default/css/print-only.css" />
How can we supply the media type in the Package definition so that the stylesheet links are correctly formed?
<link rel="stylesheet" type="text/css" href="/themes/default/css/screen-only.css" media="screen"/> <link rel="stylesheet" type="text/css" href="/themes/default/css/print-only.css" media="print"/>
I know I can use "@media" within a CSS file for different types of media, but I would like to know if it is possible to define the media type within the Package definition.
Also, using "@media" within a single CSS file is not as efficient as specifying "media" attributes. I believe a web browser downloads only the CSS files required for a given environment by looking at the "media" attribute, but when the "@media" tag is used within a CSS file, the whole file needs to be downloaded before the web browser parses out what it needs.
The "media" attribute can also consist of quite complex statements (or could in the future) such as the following:
media="screen, 3d-glasses, print and resolution > 90dpi"
Not being able to define the "media" attribute within the Package is actually an issue as far as I can see.
Thanks in advance for your assistance.