I am trying to get momentjs working on wp but it keeps telling me moment.tz is undefined and no function.
Could somebody check what is wrong with the code ?
The error you’re seeing is because the scripts are being loaded in the wrong order. You need to load Moment before loading Moment Timezone and due to the nature of $.when(), this isn’t happening. Is there any reason you’re using $.when(), BTW?
Well the “wordpress way” would be to register and enqueue them in your theme’s functions.php (or plugin entry PHP script, if that’s where they’re needed); this way you can specify which scripts depend on each other, and let WP ensure that all scripts are available when they’re needed.
Usually you can perfectly get away with just hard-coding the links at the bottom of the body, though. :-)