I'm using Emberjs to build a front end to a WordPress site. It has two javascript files 1. vendor.js and 2. myapp.js. On Ember's dev server, the app works correctly but when I add the production builds to the WordPress app, I'm getting errors which suggest that the vendor.js file is not loaded prior to myapp.js. Note, vendor.js has jQuery inside it (along with other vendor code).
This is what I'm doing to add the js files to my WordPress app. In functions.php of my theme I do
function add_my_js(){
wp_register_script('vendors', get_template_directory_uri() . '/vendor.js', array(), '20151006', true);
wp_register_script('myapp', get_template_directory_uri() . '/myapp.js', array(), '20151006', true);
wp_enqueue_script('vendors');
wp_enqueue_script('myapp');
}
add_action('wp_enqueue_scripts', 'add_my_js');
With that code, I can see (and click on) links to both js files on the front page of my WordPress app (in development server) so I know the files are both included. However, the error message I'm getting from the Ember app suggests that the vendor.js file might not be loaded at the correct time for the myapp.js file.
Question: is there another way to ensure that the first file is loaded prior to running the second file?
vendor.jsfile I am linking in has jquery included. So does thatpossiblymean two versions of jquery (one included by WordPress by default?) and the one included in the vendor.js file are getting in the way of each other?