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

Add functionality to wait for document.ready? #55

Open
W1zzardTPU opened this issue Jan 10, 2018 · 2 comments
Open

Add functionality to wait for document.ready? #55

W1zzardTPU opened this issue Jan 10, 2018 · 2 comments

Comments

@W1zzardTPU
Copy link
Contributor

W1zzardTPU commented Jan 10, 2018

What do you think about adding an internal dependency called "document", that's triggered by document.ready?

I faced random issues with jquery dependencies until I realized my jQuery code now got executed before the DOM was ready. Clearly a coding bug on my side, but it got me thinking.

My current workaround is

loadjs(["..."], 'jquery-pre'); 
loadjs.ready(['jquery-pre'], function() {
  $(function() { loadjs.done('jquery'); });
});

Not sure if worth the feature bloat for loadjs

@amorey
Copy link
Member

amorey commented Jan 10, 2018

DOM timing with jQuery can definitely get tricky. I'm hesitant to add a jQuery-specific feature but I'll think about it some more. In case it helps you can combine your loadjs calls into one:

loadjs('/path/to/jquery.js', function() {
  $(function() {loadjs.done('jquery');});
});

// execute code after jQuery document.ready
loadjs.ready('jquery', function() {
});

@W1zzardTPU
Copy link
Contributor Author

Yeah, that's what I'll use, was just waiting for the new release :)

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