jrburke/requirejs — Issue #197: Hand crafted domReady with jQuery
Author: eknkc
Created: 2012-02-28 20:44:29+00:00
State: open

Hi,

This is a follow up about a report on the newsgroup;
The thing is, I decided to implement domReady, on top of jQuery using this plugin definition (my reasoning is not really important):

```js
define("domReady", ["jquery"], function($) {
return {
load: function(resourceName, req, callback, config) {
$(callback);
}
};
});
```
When I use this, I get a timeout (on FireFox. On Chrome, it works fine at the first time but then timeouts in consecutive requests where the assets are loaded from cache. Have no idea why):

`Load timeout for modules: domReady! http://requirejs.org/docs/errors.html#timeout`

Now, If I initialize requirejs like this:

```js
require.config({
jQuery: false,
baseUrl: "/javascripts"
});
```

It starts working fine on Chrome, but fails with a timeout on Firefox just as before.
I tried including jQuery before requirejs (So it would not define itself). That did not solve the issue. However, this solves the problem completely:

```js
(function() {
jQuery.noConflict();
var jq = jQuery;
window.jQuery = undefined;

define("domReady", function() {
return {
load: function(resourceName, req, callback, config) {
jq(callback);
}
};
});
})();
```

Which means, somewhere in requirejs, there is a jQuery specific code, causing the problem. And supplying jQuery: false does not stop it from doing it also.
As a final note, curl.js executes the plugin without any problems in any setting.

Thanks.