Right after my script is loaded I am making an Ajax request to get some translations. This should always return after the document is ready since I am loading my scripts at
jQuery's when is not a proper promise. You can force it into one like this:
function documentReady() {
return Promise.resolve($.when($.ready));
}
Usage:
documentReady().then(function($) { ... });
It happens to resolve with $ so that's kind of convenient too.
Alternative implementation:
function documentReady() {
return new Promise(r => $(r));
}