"Overloaded Google Maps plugins causing sluggishness in WordPress admin panel

I recently started using the WordPress ACF plugin to create a repeater field. This feature allows administrators to add multiple markers to a Google Map on our website.

https://i.sstatic.net/0lTsi.png

Initially, our site was built to handle around 20 markers on the map. However, the client has added over 150 markers now. As a result, 150 instances of Google Maps are loading in the back-end, causing a significant slowdown in performance.

Does anyone know how to implement an asynchronous Google Map for each marker added to the field?

Answer №1

Traditional script tags in browsers require waiting for the script to download, parse, and execute before rendering subsequent HTML content. However, with asynchronous scripts, the browser can continue parsing and rendering HTML without waiting for the async script to finish. Asynchronous scripts are fetched quickly but executed when the browser's UI thread is not busy.

It's worth noting that the javascript file at maps.googleapis.com/maps/api/js is dynamic, serving different js files based on parameters.

function getScript(src) {
document.write('<' + 'script src="' + src + '"' +
' type="text/javascript"><' + '/script>');
}

Synchronous script loading requires waiting for complete load before executing, while asynchronous loading allows execution after the document is fully loaded. When using "callback=initialize" to load a script, the self-executing function already includes the initialize callback and a modified function for further asynchronous script loading.

For more details on loading Google Maps asynchronously, check out this related ticket: Loading google maps asynchronously

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to connect a value selected in a datepicker to an angular2 model?

I am currently developing an application using Angular 2 and I need to implement a datepicker specifically for Firefox, as other browsers have their own inbuilt datepicker. The issue I am facing is that when I use a datepicker, I lose the two-way binding w ...

Learn how to implement the PATCH method specifically for the scenario when the user clicks on the "forgot password"

After clicking on the forgot password link, I want to display the password change form. However, I'm facing issues with calling the API to update the user's password. Below are the files I'm utilizing to develop the API, trigger events, mana ...

Working with JavaScript to push numerous results generated by a for loop into an array

I have developed a simple system that identifies users with matching genre interests as a specific user. I am trying to store the results of the for loop in an array, but currently only the last output is being added. I want all matching results to be in ...

Navigating with Reach Router only updates the URL, not the component being rendered

Is there a way to programmatically navigate using Reach Router in React? I have noticed that when updating the URL, the route does not render. Even though the URL changes, the original component remains displayed according to the React developer tools. Ho ...

Tradebot for Node.js powered by Steam

I have created a Node.js Steam Bot using modules like steam user, steam trade, steamcommunity, and steam-tradeoffer-manager, among others. var username = "bot"; var password = "123456"; var steamguard = ""; var Steam = require('steam'); var St ...

An error is thrown when attempting to access a generic type 'T' within an array

I'm working with the following code: interface Process<T> { first: () => T[]; second: (d: T) => void; } const PROCESSES: Process<T>[] = [ { first: () => [{car: "car1"}], second: (car: {car: string}) => ...

Instead of receiving my custom JSON error message, Express is showing the server's default HTML error page when returning errors

I have set up a REST api on an Express server, with a React app for the front-end. The design includes sending JSON to the front-end in case of errors, which can be used to display error messages such as modals on the client side. Below is an example from ...

Challenges encountered while dynamically generating buttons using jQuery

I am currently struggling to dynamically incorporate operator buttons into my calculator. Although I have successfully created functions to generate number and operator buttons, I am facing difficulty with the latter. The numbers are being generated withou ...

Generate various buttons dynamically using server-side Ajax data table

Below is the table structure: <table id="example" class="display" cellspacing="0" width="100%"> <thead> <tr> <th>Name</th> <th>Position</th> <th>Office</th ...

Method not found in Angular

I am currently working on an Angular application with a C# backend that exposes services. I am trying to use AngularJS resources to access these services. However, when I call the resource in the controller, I am encountering the following error: TypeErro ...

Is it recommended to utilize the useRef hook when storing data that is only initialized once?

When it comes to using react's ref nowadays, things can get a bit confusing. In the past, with class components, the documentation was pretty straightforward. Refs are primarily meant for DOM elements: https://reactjs.org/docs/refs-and-the-dom.html ...

What steps should I take to resolve the "undefined property match cannot be read" error that's showing up in this code?

Currently, I am facing an issue while attempting to integrate the nativescript-imagepicker plugin into my Nativescript App. I keep receiving an error message stating **cannot read **property match of undefined**. Below is a summary of the steps I have take ...

How can I utilize Luxon to calculate the total number of days that are equal to or greater than 30?

Looking at my current array structure const arr = [ { id: '1', name: 'thing1', createdAt: '2022-09-21T16:26:02Z', }, { id: '2', name: 'thing1', createdAt: '2022-11-21T16:20:20Z', } ...

Sending numerous forms simultaneously with a single click using Ajax technology

Whenever I click a single button, I am handling the submission of multiple forms. For example, if there are two forms on the page, clicking the button will show that $('form[id^=buyerForm]').length is equal to 2. During the first iteration, the ...

Animate the opening and closing of a div element

A form is set up for editing. Within this form, there are 2 separate divs. The first div is labeled editForm, which displays the form for editing, and the second div is labeled infos, which shows the details of this form. My goal is to have the infos se ...

What is the reason for function components running in multiples of 2 when the state changes?

I need help with a React question that I can't quite figure out. I have a component where new data keeps getting added to the existing data. Initially, it makes sense for two console logs to appear due to Mount and Update. But after that, why do 4 con ...

Infinite scroll functionality does not function properly with jQuery

I recently completed a custom WordPress theme and implemented the following script to create an accordion-like effect: ( function( $ ) { var $ele = $('.entry-content').hide(); $(".entry-header").click(function(e) { e.preventDef ...

Is there a way to create an interactive animation where an image responds to the movement of the mouse, but does not directly follow it

Looking to create an interactive experience where images on the webpage move in response to mouse movement. For example, if an image is at coordinates (0,0) and the mouse moves from (32,45) to (32,47), the image should shift vertically by 2 pixels. I atte ...

Is it feasible to maintain a persistent login session in Firebase without utilizing the firebase-admin package through the use of session cookies?

Currently, I am integrating Firebase into my next.js application for user login functionality. The issue I am facing is that users are getting logged out every time they switch paths within the site. Even though their session cookie has not expired, if the ...

Restricting the type of user input in HTML forms

Requirements: Input must be a whole number between 2 and 99, inclusive. Current Solution: <input required type="number" min="2" max="99" oninput="this.value = Math.abs(this.value)" maxLength="2" matInp ...