Ticket #2529521 (closed enhancement)
Reporter Jeff Craig |
Opened: 11/10/10 Last modified: 05/10/12 Status: closed Type: enhancement Resolution: fixed |
Owner Dav Glass |
Target Release: 3.5.0 Priority: P3 (normal) |
|---|---|---|---|
| Summary: | Consider making the presence of YUI CSS detectable by the loader | ||
| Description: | It is possible to include the CSS modules of YUI (grids, fonts, reset, etc) using loader via a 'use' statement, as was pointed out by Matt Sweeney during his YUIConf talk on YUI3 Grids. However, if If a different combo URI is generated out of loader, this will result in an extra request, otherwise the browser will reprocess the CSS unnecessarily, and it could impact the cascade as well. |
||
| Type: | enhancement | Observed in Version: | 3.3.0 PR1 |
| Component: | Loader | Severity: | S3 (normal) |
| Assigned To: | Dav Glass | Target Release: | 3.5.0 |
| Location: | Library Code | Priority: | P3 (normal) |
| Tags: | Relates To: | ||
| Browsers: | All | ||
| URL: | |||
| Test Information: | <html> |
||
Change History
|
Posted: 11/10/10
|
|
Posted: 11/11/10
This report came out of a question asked during Matt Sweeney's talk, where someone asked how, if they were making a widget that depended on Grids, how could they know if the grids was available, to which Matt replied that it could be listed as 'required' in the users 'add' statement. This is where I potentially see this actually getting triggered. I'll be honest, I really don't have an answer, and with CSS3 grids being fairly small, it may not be worth looking at too closely, as the only way I can think to address it would be to have loader do a pattern match against the href's in the link tags in the header, or looking for yui3-g or yui3-u classes on the page. Both of these add overhead and are not necessarily reliable, though there results could be cached, so it would be a one-time check which could potentially be deferred using the conditional loading code in the loader framework. This may well be a WONTFIX or INVALID issue, as it's hard to say if it's even likely to be triggered, or if it being triggered is a problem, I did notice that Loader won't reload CSS Grids if YUI().use('cssgrids') is executed again, so Loader already has a small amount of smarts on this, but it seemed like something that there *may* be a solution to, even if it's not something that warrants immediate attention. |
|
Posted: 11/22/10
As things are now, there isn't a good way to know what YUI CSS is on the page. Normally this isn't a huge hurdle, but if we want to try to do something about it we could consider adding a convention to the css that would be detectable by the loader. |
|
Posted: 12/2/10
|
|
Posted: 04/20/11
|
|
Posted: 04/26/11
I have considered testing "fake" properties in the CSS build file's to determine if they loaded.. Something like this at the bottom of the grids file (generated by builder): body { Note: I haven't tested this and I'm not sure if it would even work. |
|
Posted: 11/8/11
|
|
Posted: 11/8/11
Matt Sweeney and I discussed this at YUIConf last week and came up with this prototype: When YUI stamps the page, it creates an element called #yui-css-enabler Then Loader can add the class to the element and check if the style is applied. If it is, the CSS file is loaded, if it is not, load it.. |
|
Posted: 12/1/11
Pull request for this code: https://github.com/yui/yui3/pull/56 |
|
Posted: 12/2/11
|
|
Posted: 12/2/11
Fixes #2529521 - Added CSS Stamp detection for pre-loaded CSS files. |
|
Posted: 12/6/11
Fixes #2529521 - Added CSS Stamp detection for pre-loaded CSS files. |
|
Posted: 05/10/12
checkedin -> closed |
CSS files can't register themselves with YUI like the script files can, so there isn't a reliable way to know you pre-loaded it. But you can tell YUI that you've done so.
If you want to front load all your css, you can set 'fetchCSS' to false.
If you want to front load some of the CSS, and not the rest, you can use the 'ignore' config
ignore: ['css-fonts', ...
Does that help?