Title: Creating javascript hook when using new full site editing
Last modified: July 16, 2022

---

# Creating javascript hook when using new full site editing

 *  Resolved [wiekafe](https://wordpress.org/support/users/wiekafe/)
 * (@wiekafe)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/creating-javascript-hook-when-using-new-full-site-editing/)
 * Hey,
    I was following this guide: [https://www.youtube.com/watch?v=wwxYvxsknmM](https://www.youtube.com/watch?v=wwxYvxsknmM)
   and I got it working earlier. After updating to a theme that support full site
   editing, I can’t directly edit the footer.php file to setup mapster hook, and
   I can’t get it to work anymore. In order to add the javascript mapster hooks 
   needed, I installed the ‘Insert Headers and Footers’-plugin and tried to add 
   the scripts with that. However, I get the error ‘mwm is not defined’. How could
   I get a reference to mwm, or where is it defined? The video doesn’t really explain
   it.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [wiekafe](https://wordpress.org/support/users/wiekafe/)
 * (@wiekafe)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/creating-javascript-hook-when-using-new-full-site-editing/#post-15831520)
 * I figured that mwm is defined after my script runs, and that’s why my script 
   can’t find it. I made the script wait until mwm is defined, but maybe there is
   a better solution?
 *  Plugin Author [mapster](https://wordpress.org/support/users/mapster/)
 * (@mapster)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/creating-javascript-hook-when-using-new-full-site-editing/#post-15831528)
 * Hello! First off thanks for using the plugin, hope it’s working nicely for you.
 * The “mwm” is defined when the Mapster scripts start up, which is basically once
   they are loaded onto the page (they have a dependency on jQuery and then some
   internal dependencies, such as loading the Mapbox library and so on). WordPress
   can be tough in terms of knowing exactly which scripts are loading before which
   other scripts, especially when you’re using plugins like you described that are
   inserting scripts at different places.
 * You’re probably safe if you wait for the jQuery loading event before calling `
   mwm`. If you’re not sure, safest to call `window.mwm` since it’s defined globally.
   However, your solution also works great — basically using some kind of setInterval
   to check if window.mwm is defined before doing your custom scripts. I think you
   probably have it figured out!
 * Let me know if you need any more help.
 *  Thread Starter [wiekafe](https://wordpress.org/support/users/wiekafe/)
 * (@wiekafe)
 * [3 years, 10 months ago](https://wordpress.org/support/topic/creating-javascript-hook-when-using-new-full-site-editing/#post-15831603)
 * Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Creating javascript hook when using new full site editing’ is closed 
to new replies.

 * ![](https://ps.w.org/mapster-wp-maps/assets/icon-256x256.png?rev=3132969)
 * [Mapster WP Maps](https://wordpress.org/plugins/mapster-wp-maps/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mapster-wp-maps/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mapster-wp-maps/)
 * [Active Topics](https://wordpress.org/support/plugin/mapster-wp-maps/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mapster-wp-maps/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mapster-wp-maps/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [wiekafe](https://wordpress.org/support/users/wiekafe/)
 * Last activity: [3 years, 10 months ago](https://wordpress.org/support/topic/creating-javascript-hook-when-using-new-full-site-editing/#post-15831603)
 * Status: resolved