JS variable loaded using wp_localize_script is no longer available

TL;DR: Call the wp_localize_script after registering/enqueuing the script you are localizing. Recently (WP 4.1.4 / WP 4.2) my ajax scripts stopped working. I’ve noticed that it was caused by the fact that the variable for the ajax_url was undefined so for some reason it ws no longer loaded to the page. The reason turned out… Continue reading JS variable loaded using wp_localize_script is no longer available