Skip to content
This repository has been archived by the owner on May 9, 2019. It is now read-only.

Move inline JS into file not working due to template load order of config localization #794

Open
claytoncollie opened this issue Sep 25, 2018 · 0 comments

Comments

@claytoncollie
Copy link

claytoncollie commented Sep 25, 2018

What did you expect to happen?

I made my own templates for instantsearch and autocomplete and in the process moved all of the JS into a file instead of injecting it inline. I expected the Algolia config to be available via localization so that I could use it on my JS files.

What happened instead?

The template loader injects the config localization in wp_head instead of through wp_enqueue_scripts so I cannot change the priority order to have the config come before any JS is loaded. I was able to get my results showing by putting my custom JS in the footer and leave the config in the header. The downside to this is the DOM loads the markup as empty containers, then a second later, flashes in the search results. I would think it would be more seamless if the JS files and the config parameter are loaded in the head.

Any idea on how I can get around this problem?

Seems to me like the localization should be using the wp_enqueue_scripts hook instead of wp_head

image

Technical info

  • WordPress version: 4.9.8
  • Algolia Search plugin version: 2.11.2
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant