Ticket #2529081 (closed enhancement)

Reporter


Alexander
Opened: 07/20/10
Last modified: 04/20/11
Status: closed
Type: enhancement
Resolution: duplicate
Duplicate of: #2528670

Owner


Ryan Grove
Target Release: FUTURE
Priority: P3 (normal)
Summary: Correct loading CSS in Gecko and Webkit
Description:

As we know, nor Gecko nor Webkit not support onload and onerror for <link> nodes. Ordinary, but partially working solution is poll .sheet property until timeout. But i discovered different ways to
load css and found that if we load css via <object>, onload correctly fired even in crossdomain situation. But, unfortunately, onerror still not. To fix it we use two separate techniques for Webkit
and for Firefox

Webkit
We poll .sheet propery until it not null or not timeout (big timeout, for example 30s).
If sheet property is not null but <object> onload not fired still - it mean error of loading css.

Gecko
Unfortunately in gecko .sheet property present in <link> as soon as <link> created. We can not poll it. Solution i found is load css via <script>. Onload and onerror events fires correcty. But if css
loaded correctly, it is parsed as javascript code and, obliviously, error console is spamed by Syntax errors. Also js error prevent loading and executing other scripts (as i know). Solution is load
<script> in <iframe>. And onerror event firing mean that css not loaded, onload mean ok (but <object> onload also firing).

Algorithm

if gecko then create <iframe> previously;

Create <object> with data = url, width = height = 1 and style.display = 'block' (yes, object like flash not loads if not visible ), onload = _onObjectLoad handler function.
Also run .sheet poll periodically if webkit, or parallel load css as <script> if gecko after, for example, 5 s. In most cases you not reach this 5s timeout.

P.S. Sorry about my engrish :(.

Type: enhancement Observed in Version: 3.1.1
Component: Get Utility Severity: S3 (normal)
Assigned To: Ryan Grove Target Release: FUTURE
Location: Priority: P3 (normal)
Tags: css, webkit, gecko, load Relates To:
Browsers: Firefox 3.x - All,Firefox 3.x - Mac,Firefox 3.x - PC,Safari 4.x - Mac,Safari 4.x - PC
URL: http://github.com/bga/jbasis/blob/001e8515e44c0688e77faeb79ad38ee0ce73c578/src/$jb.Loader.CSSResource.js
Test Information:

Change History

Alexander

Posted: 07/24/10

My implementation now not use iframe for gecko . Also bugs fixed http://github.com/bga/jbasis/commit/548511245b707666e68954340d3b195ad6eca845

Adam Moore

YUI Contributor

Posted: 08/11/10
  • milestone changed to FUTURE
  • priority changed to P3 (normal)
  • status changed from new to accepted

Adam Moore

YUI Contributor

Posted: 08/11/10

This is interesting, but I'm not sure the extra overhead is worth it. Marking for future investigation.

George

YUI Developer

Posted: 04/20/11

Ryan Grove

YUI Developer

Posted: 04/20/11
  • browser changed from Firefox 2.x - All,Firefox 2.x - Mac,Firefox 2.x - PC,Firefox 3.x - All,Firefox 3.x - Mac,Firefox 3.x - PC,Safari 3.x - All,Safari 3.x - Mac,Safari 3.x - PC,Safari 4.x - Mac,Safari 4.x - PC to Firefox 3.x - All,Firefox 3.x - Mac,Firefox 3.x - PC,Safari 4.x - Mac,Safari 4.x - PC
  • duplicate changed to 2528670
  • resolution changed to duplicate
  • status changed from assigned to closed

This ticket was marked as a duplicate of #2528670