Async widgets.js loader is not compatible with oct.js (initialize different twttr object -- missing "ready")


in async loader we have:

return window.twttr || (t = {_e: [], ready: function(f) {

which prepares the convenient ‘ready’ function.

use this with oct.js, you will lost ‘ready’ function. because there’s no such ‘_e’ and ‘ready’ initialized for oct.js’s twttr object (unless you can make sure async code finishes first before oct.js).

This is my current solution now:

window.twttr = (function(d, s, id) {
          var t, js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id))
          js = d.createElement(s);
 = id;
          js.src = "";
          fjs.parentNode.insertBefore(js, fjs);
          // make async loader compatible with oct.js
          var _twttr = window.twttr || (t = {_e: [], ready: function(f) {
          if (! ('_e' in _twttr)) {
            _twttr._e = []
          if (! ('ready' in _twttr)) {
            _twttr.ready = function(f) {
          return _twttr
        }(document, "script", "twitter-wjs"));

Async widgets.js loader is not compatible with oct.js

Hi Akhmad, thanks for letting us know about this. We’ll post a revised version of the async loader code soon. In the mean time, I’m glad you were able to get it working.



Thanks for posting the workaround, Akhmad. Just run into this myself!


Any official update on this one? It still seems broken.


Is there any update to this issue ?
Following twitter official guides on both widget.js and oct.js and placing them both at the same page I will end up with twttr.ready() bombing out due to undefined as described by neofreko. The work around works fine, but I think you twitter guys should address this issue or at least warn about it in your guides ! This issue just caused us broken page in production - no ideal !


Hi everyone. Sorry this took so long to get proper attention. We’ve updated our docs with a version of the async code node which fixes the assignment of ready() for coexistence with oct.js. Thanks to everyone who contributed workarounds in the interim.


closed #7