HeadJS ready for both document and script
- by Yashua
Current code:
head.ready(function() {
console.log($('.thing a').val());
});
It will sometimes fail with error that $ is not ready.
I have loaded jquuery earlier with the label 'jquery'. Neither of these work:
head.ready(document, function() {
console.log($('.thing a').val());
});
head.ready('jquery', function() {
console.log($('.thing a').val());
});
I would like to not do this if possible:
head.ready(document, function() {
head.ready('jquery', function() {
console.log($('.thing a').val());
});
});
And also avoid refactoring current code to place that snippet at bottom of body though that I think may be the solution.
Is it possible with HeadJS to define a ready call() using head.ready(), that is not placed at the bottom, that will wait for both a labeled script and the DOM to be loaded?
UPDATE: the nested script doesn't actually work. I think the inner one erases/superseds the other :(