Meetings Tool won't Display in WordPress Page

engagements
forms

#1

Hi! I have a vexing problem. When I’m logged into WordPress, and load the About page, the Meetings tool loads correctly. However, if I log out of WordPress and reload the page, the Meetings tool no longer loads. It throws TypeError: i is undefined.

web page URL: https://vmsolu.com/about/

Embed code:

To see what would happen, I created a skeleton HTML page and added the embed code to it, along with the hs load script in the head, as follows:

VMS Meetings Widget Test

The Meetings tool loads correctly from this HTML.

I’m at a loss for the cause of this problem. In WordPress, it’s obvious that the embed script itself is probably being loaded before a dependency, but why this only happens when I’m logged out of WordPress is beyond me. The load script loads all scripts, regardless of WP login status.

Any ideas?


#2

I think I have solved this issue for myself, but would like to share the solution so others won’t spend the time I have trying to resolve this.

Corrective action taken: Manually load the Meeting tool embed code’s javascript in the footer after its dependency.

Process:

  1. Remove the javascript from the embed code.
  2. Create a unique function in theme/child theme functions.php

function my_unique_function() { wp_enqueue_script('dependency script handle', 'dependency script source'); wp_enqueue_script('static.hsappstatic.net/MeetingsEmbed/ex/MeetingsEmbedCode', 'https://'static.hsappstatic.net/MeetingsEmbed/ex/MeetingsEmbedCode.js', 'dependency script handle', array('jquery'), true); } add_action('wp_enqueue_scripts', 'my_unique_function');

  1. Purge caches for website

Voila! Meetings tool works in WordPress page.

Reason for this particular solution: When logged out of WordPress, the embed script kept loading before its dependency. This threw the error mentioned earlier. In an effort to preserve the embed code structure, I tried several alternative solutions. None of them worked. The solution above was a last-resort effort that still attempted to see if it would work.

Hopefully, this will help others with WordPress websites that use Hubspot Meetings or other tools.