1

I'm trying to build a plugin and enqueue my scripts to footer. For performance reasons I'd like to load this plugin scripts after the functions.php scripts, because furthermore it will break the page otherwise.

I mean that in my functions.php there are essentials scripts like:

  • jquery
  • jquery-ui

which are loaded in the header. Next I have other essentials scripts, always in my functions.php, that are loaded in footer like:

-------FOOTER

  • jquery-migrate
  • hoverintent

etc... The problem is that when I load the plugin scriptS in footer they load just before the others in functions.php like:

------- FOOTER

  • HERE PLUGIN SCRIPTS

  • jquery-migrate (from functions.php)
  • hoverintent (from functions.php)

This makes the website break because some of the plugin scripts depends by the others loaded next. I guess it's a priority problem but I don't know how to handle that. I'm using the right hook for this according to codex:

wp_enqueue_script('typeahead bundle', 'https://cdnjs.cloudflare.com/ajax/libs/typeahead.js/0.10.4/dist/typeahead.bundle.min.js', array('jquery', 'hoverintent') , false, true);

Even setting the array with dependencies it won't work. What am I doing wrong? Thanks.

1 Answer 1

2

I don't think the name (typeahead bundle) may contain spaces.

1
  • I've checked I did this mistake. Damn! That's great thank you!
    – middlelady
    Commented Jul 3, 2016 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.