Wp-rocket: Avada - Google Maps not being displayed

Created on 14 Dec 2020  Â·  1Comment  Â·  Source: wp-media/wp-rocket

Before submitting an issue please check that you’ve completed the following steps:

  • Made sure you’re on the latest version ✅ I used WP Rocket 3.8 patched with #3402
  • Used the search feature to ensure that the bug hasn’t been reported before ✅

Describe the bug

Google Maps aren't displayed when they are added using the Avada Builder.

The issue is resolved when excluding the following file from deferring:

https://maps.googleapis.com/maps/api/js

To Reproduce

Steps to reproduce the behavior:

  1. Use Avada's builder to add a Map to a page.
  2. Enable JavaScript deferring.
  3. The map won't be loaded.

Expected behavior

Google Maps should be loading.

Additional context

Related tickets:

Backlog Grooming (for WP Media dev team use only)

  • [ ] Reproduce the problem
  • [ ] Identify the root cause
  • [ ] Scope a solution
  • [ ] Estimate the effort
3rd party compatibility [S] file optimization medium bug

Most helpful comment

Reproduce the issue ✅

Reproduced on our Avada test site

Identify the root cause ✅

The inline JS added by Avada when there is a Google Maps added with the Avada Builder is not compatible with our defer inline JS in 3.8. The inline JS is using jQuery, and the variables defined in it need to be in the global scope, which is no longer the case when wrapping them with our event listener.

Scope a solution ✅

We need to always exclude both jQuery and Google Maps from deferring when using Avada to prevent issues. This can be done with a new function in 3rd-party/themes/avada.php, hooked on our rocket_exclude_defer_js filter.

Estimate the effort ✅

Effort [S]

>All comments

Reproduce the issue ✅

Reproduced on our Avada test site

Identify the root cause ✅

The inline JS added by Avada when there is a Google Maps added with the Avada Builder is not compatible with our defer inline JS in 3.8. The inline JS is using jQuery, and the variables defined in it need to be in the global scope, which is no longer the case when wrapping them with our event listener.

Scope a solution ✅

We need to always exclude both jQuery and Google Maps from deferring when using Avada to prevent issues. This can be done with a new function in 3rd-party/themes/avada.php, hooked on our rocket_exclude_defer_js filter.

Estimate the effort ✅

Effort [S]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

piotrbak picture piotrbak  Â·  4Comments

arunbasillal picture arunbasillal  Â·  4Comments

Tabrisrp picture Tabrisrp  Â·  4Comments

Screenfeed picture Screenfeed  Â·  5Comments

crystinutzaa picture crystinutzaa  Â·  4Comments