Unison icon indicating copy to clipboard operation
Unison copied to clipboard

DOMContentLoaded fired before loading Unison

Open Strajk opened this issue 11 years ago • 1 comments

I'm using Unison with Require.js

require.config({
    paths: {
    unison: '../bower_components/unison/js/unison'
  },
    shim: {
        'unison': { exports: 'Unison' }
    }
});

But then, Unison is loaded after DOMContentLoaded event, and because Unison is registering listener to that event to initialize itself, it will not start correctly.

doc.addEventListener('DOMContentLoaded', function(){
      unisonReady = win.getComputedStyle(head, null).getPropertyValue('clear') !== 'none';
      breakpoints.update();
    });

I managed to fix it, but I'm not sure if it's good approach

if (document.readyState == "complete" || document.readyState == "loaded") {
     // init()
} else {
  doc.addEventListener('DOMContentLoaded', function(){
    // init();
  });
}

Strajk avatar Aug 22 '14 13:08 Strajk

+1, ran into this same scenario. @Strajk you may want to look at #15 , it looks like a solve for this

weotch avatar Dec 12 '14 00:12 weotch