Skip to content

Instantly share code, notes, and snippets.

@lsmith
Created May 25, 2010 19:37
Show Gist options
  • Save lsmith/413584 to your computer and use it in GitHub Desktop.
Save lsmith/413584 to your computer and use it in GitHub Desktop.
// The plan
1. find the <script> pointing to yui(?:-(?:debug|min)).js -- this could be a combo file
2. Right after it, inject <script src="http://yui.yahooapis.com/(version)/build/io/io-base-min.js"></script> followed by a <script> pointing to your io override module.
- The static inclusion of io-base will add it to the YUI.Env.mods collection, preventing Loader from fetching the module
3. In your script, replace the YUI.Env.mods['io-base'] entry with your module's entry, and store off the existing io-base module entry under a different name. Specify this other name as a requirement for your module.
4. Profit (hopefully).
- YUI().use('whatever',...) should resolve dependencies, identifying your module as io-base, and requiring the real io-base be executed before yours (to facilitate proper overwriting)
<!-- the result should look like this -->
<script src="http://yui.yahooapis.com/3.1.1/build/yui/yui-min.js"></script>
<!-- injected -->
<script src="http://yui.yahooapis.com/3.1.1/build/io/io-base-min.js"></script>
<script src="/path/to/mymodule.js"></script>
<!-- end injected -->
<script>
YUI().use('io', function (Y) {.... });
</script>
YUI.add('some-unique-module-name', function (Y) {
Y.Do.before(function () {
var args = Y.Array(arguments, 0, true);
args[0] = YAHOOULT.ULT.CHECKER.rewrite_link(uri);
return new Y.Do.AlterArgs("Updating url for debug tracking", args);
}, Y, 'io');
}, '0.0.1', { requires: [ 'io-base-original', 'event-custom-base' ] });
YUI.Env.mods['io-base-original'] = YUI.Env.mods['io-base'];
YUI.Env.mods['io-base'] = YUI.Env.mods['some-unique-module-name'];
delete YUI.Env.mods['some-unique-module-name'];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment