BackendPro 0.6.1 |
[eluser]adamp1[/eluser]
This is my problem at the moment. So currently its implemented to cache but browser specific rules don't work. Unless I can find a solution for both then I will most likely get rid of the server caching and make sure browser specific stylesheets work (as in your code). Like you say I'm not happy about hacks, I have to admit when I first wrote the asset library for BackendPro I didn't know the comments where HTML only (thought they were CSS). So as soon as exams are over I most likely will release a browser specific version. Thank you for the work on it btw, hope your finding the application as a whole helpfull.
[eluser]ddrury[/eluser]
Adam, Thinking about how you've currently implemented the file caching, I think there is a fundamental problem. If you're amalgamating a number of files then surely the browser's html should only have one include line for the amalgamated .js or .css file but currently there is a line generated for each 'original' file so even if a server cache is built I don't think it'll be used. Have you seen this site http://www.ejeliot.com/blog/72. Further thinking; should you get this sorted is there not some way to make the ie conditional files avoid the cache altogether? Thus you'd end up with something like this in the browser Code: <link rel="stylesheet" type="text/css" href="combinedstuff.css"> Dave
[eluser]adamp1[/eluser]
You mustn't have turned server caching on. When it is on there is only 1 include line for css and js. I will have to look into the browser specific styles as said (as said before it as to wait a week or so)
[eluser]ddrury[/eluser]
Hi Adam, You were right - caching was off. Further thoughts on the css files, howabout creating another array in modules\page\config\page.php something like $config['default_assets'] = array(admin(..),public(..),shared(css(..),js(..),conditional(..)) to hold all these conditional files (named along the lines I suggested earlier) and then either just load them wrapped in a conditional comment with set_asset or (thinking aloud) use the user_agent class to check them against the current browser and only load as required. Either way they won't be loaded in the main cache. Dave
[eluser]ddrury[/eluser]
Right! I think this works and may form the basis for the way forward. In modules\page\config\page.php create new arrays 'cond_css' for each of the admin,public & shared areas. In modules\page\libraries\Page.php. modify function output_assets() to handle 'cond_css' (2 lines marked with comment) create new function _include_cond_css to handle the output. BTW in the release version of the code you call for navigation.css in the admin area but it's missing! Dave Code: $config['default_assets'] = array(
[eluser]adamp1[/eluser]
Ill have a look at this soonish, thanks for the input.
[eluser]ddrury[/eluser]
Hi Adam, Hope the finals are going (have gone?) well! I've been thinking further about this asset loading lark. My latest changes work and allow conditional loading of css (and potentially javascript), however, because of the loading sequence the Page class uses (e.g shared-js, shared-css, shared-cond_css followed by admin-js, admin-css, admin-cond_css) the shared-cond_css virtually becomes redundant because of the likelyhood of being overwritten later on. Hunting around on the web turned up this; http://railsify.com/plugins/109-holly (which is written in Ruby and is complete garbage to me!), however the gist is to put a special comment block at the top of each javascript and css file that lists up & downstream rquirements which is then parsed by Holly and a correctly sequenced loading list of files is built. I was thinking of perhaps extending the parsing logic to include some conditional checks. Once this (complete) file list is build it could then be submitted to the cache builder. Hey presto only two files to load.. one javascript & one css. What do you think? Dave
[eluser]adamp1[/eluser]
Ummm I do like the sound of that, that way only the CSS and Javascript required is loaded. Only thing is I only see this being of any use say, when you have javascript libraries which are only loaded on some pages (say that they need the jQuery base library, this way jQuery would only be loaded when needed). You say things get over ridden when loading admin styles after shared. Surely this will happen also with the Holly approach, I don't see this overriding thing as an issue. Surely that's a feature you want in CSS. If you see how I have structured css files shared files are either very basic (I.E reset browser styles to default) or little css files used throughout (I.E the style for status messages). So I do like the idea but can't really see much use for it (it would be a nice feature but I don't think it is as necessary as having conditional css style sheets working atm). Finals are this next week so all I am looking at now is lots and lots of books
[eluser]ddrury[/eluser]
OK I take your point, however I really should allow time for my brain to wake up before posting messages. Of course any file where loading is conditional should have it's own load line in the generated html (cached or not) otherwise it wouldn't be conditional!!! Dave
[eluser]adamp1[/eluser]
Yes, from this I think I have a brief idea of what I will do. 1) As you have mentioned allow conditional files (CSS only) to be specified in the config file. 2) Implement caching as currently, but only cache shared/public/admin files, conditional files will always be loaded separately. 3) Implement jsmin and csstidy plugin libraries to allow for better compression of cache. I think those several features should allow the Asset system to be both simple and powerful. |
Welcome Guest, Not a member yet? Register Sign In |