Forums

Posting in these forums is disabled. These forums will be available for archive purposes. Please join the new forums at the links below:

  • yui-support - replaces the `YUI 3.x` and `YUI 3 Gallery` forums.
    We have created the following discussion categories within this group to aid discoverability for these most-used topics:
    • Charts for YUI Charts support.
    • DataTable for YUI DataTable support.
    • Gallery for YUI Gallery support, including support for published Gallery components as well as the Gallery process in general.
    • Tools for support of YUI’s suite of developer tools such as selleck, shifter, grover, yogi, etc.
    • Everything Else for questions that don’t fit one of the categories above, we’ve got you covered here.
  • yui-deprecated - replaces the `YUI 2.x` forum and the forums of other deprecated products (`YUI Doc`, `Builder`, `YUI PHP Loader`, etc.).
  [ 3 posts ]
New Topic | Post Reply | Print view
Previous topic | Next topic

Joseph Chiang

YUI Contributor

  • Username: josephj
  • Joined: Thu Sep 03, 2009 2:54 pm
  • Posts: 7
  • Location: Taipei, Taiwan
  • Twitter: josephj6802
  • GitHub: josephj
  • Gists: josephj
  • IRC: josephj
  • Offline
  • Profile
Tags:
  • contentready
  • non-blocking

contentready fails when using Non-blocking JS in IE

Post Posted: Mon Feb 14, 2011 1:49 am
Hi,

My page has only one JavaScript file containing all the YUI dependecies I need. (It's a big JavaScript.)
I use Non-blocking JavaScript instead of putting it on the bottom of page for better usability.

Code:
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>contentready</title>
<script type="text/javascript">
(function(){
  var scriptEl   = document.createElement("script");
  scriptEl.src   = "init.js";
  scriptEl.type  = "text/javascript";
  scriptEl.async = "true";
  document.getElementsByTagName("head")[0].appendChild(scriptEl);
}());
</script>
</head>


In init.js, I use contentready to execute as soon as possible.
Code:
Y.on("contentready", function () {
    alert("foo executed");
}, "#foo");

All browsers work fine except IEs.

Finally I realize in IEs, non-blocking JavaScript doesn't trigger onload handler which YUI assigns.
It causes _loadComplete variable in _onContentReady function always be false and has infinite loops.

My workaround is using "available" instead. (It might cause other errors)
And I still want to use non-blocking JavaScript.
Anyone has a better solution for this?

Alberto Santini

YUI Contributor

  • Offline
  • Profile

Re: contentready fails when using Non-blocking JS in IE

Post Posted: Mon Feb 14, 2011 4:15 am
Hello Joseph.

Maybe the following resources might help you:

Non-blocking JavaScript Downloads
http://www.yuiblog.com/blog/2008/07/22/ ... g-scripts/

Loading JavaScript without blocking
http://www.nczonline.net/blog/2009/06/2 ... -blocking/

JS Performance and YUI3
http://www.yiotabytes.com/2010/08/javas ... -yui3.html

Hope that helps,
IceBox

Caridy Patino

YUI Contributor

  • Username: caridy
  • Joined: Mon Dec 08, 2008 5:40 pm
  • Posts: 494
  • Location: Miami, FL
  • Twitter: caridy
  • GitHub: caridy
  • Gists: caridy
  • IRC: caridy
  • YUI Developer
  • Offline
  • Profile
Tags:
  • yui
  • loader
  • dynamically
  • injection
  • strategy

Re: contentready fails when using Non-blocking JS in IE

Post Posted: Sat Feb 19, 2011 7:37 am
Hey Joseph,

If YUI seed will be injected dynamically you have to specify it in the configuration.

http://developer.yahoo.com/yui/3/api/co ... y_injected

You can add this in your JS block:
Code:
(function(){
  YUI_config = {injected : true};
  var scriptEl   = document.createElement("script");
  scriptEl.src   = "init.js";
  scriptEl.type  = "text/javascript";
  scriptEl.async = "true";
  document.getElementsByTagName("head")[0].appendChild(scriptEl);
}());


That piece of configuration will tell the SEED that if was injected dynamically, and you not wait for domready/load/contentready/etc, instead if should simulate them.

This is very useful if you're using a rollout version of the library in productionI talked about this concept in my YUIConf talk: http://www.yuiblog.com/blog/2010/12/02/ ... 10-caridy/

Best Regards,
Caridy
  [ 3 posts ]
New Topic | Post Reply | Print view
Previous topic | Next topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum