wp_loaded hook block script enquequing

You can’t enqueue because wp_loaded is too early.

To enqueue scripts and styles, you need to do it on the wp_enqueue_scripts type hooks, but because your exiting on wp_loaded, none of those hooks have fired yet.

Additionally, you need to have the necessary function calls in the template for it to enqueue them into, such as wp_head or wp_footer, otherwise there is no opportunity to generate the script and link tags

So your options are:

  • use a later hook than wp_loaded that happens after the scripts have been enqueued
  • include the scripts manually inline