Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOMContentLoaded fired before loading Unison #16

Open
Strajk opened this issue Aug 22, 2014 · 1 comment
Open

DOMContentLoaded fired before loading Unison #16

Strajk opened this issue Aug 22, 2014 · 1 comment

Comments

@Strajk
Copy link

Strajk commented Aug 22, 2014

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();
  });
}
@weotch
Copy link

weotch commented Dec 12, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants