A Chrome App I've made works perfectly fine for me, but another user gets an error Uncaught ReferenceError: Promise is not defined
when starting it up. For some reason it doesn't understand what a Promise is. The code works perfectly fine on my end and I've never gotten that error before, but the user gets it every time. What could be the issue here?
Answer: Execute Code after jQuery Library has Loaded The most common reason behind the error "Uncaught ReferenceError: $ is not defined" is executing the jQuery code before the jQuery library file has loaded. Therefore make sure that you're executing the jQuery code only after jQuery library file has finished loading.
The Javascript ReferenceError occurs when referencing a variable that does not exist or has not yet been initialized in the current scope.
A Promise is a JavaScript object that links producing code and consuming code.
The user updated Chrome to the latest version and that apparently fixed it. I don't know how, since his version was from December 2013 and surely Promises worked back then. I don't know. It definitely isn't a problem with the code since I'm running the same exact version the user is running and I've never encountered that error.
But yeah - apparently fixed.
EDIT: Apparently Promises only work since Chrome 32, so yeah that's why the error.
To support IE and older versions of other browsers, you should consider loading a polyfill for the Promise object.
One implementation you can use out of the box with a <script>
tag is available here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With