onOffice-Web-Org / oo-wp-plugin

onOffice for WP-Websites
https://wp-plugin.onoffice.com
GNU General Public License v3.0
9 stars 9 forks source link

Proper loading of Google Maps JS API in onOffice Plugin #722

Open fredericalpers opened 10 months ago

fredericalpers commented 10 months ago

Initiative

Improve the onOffice for WP-Websites Plugins' usability and performance

Epic

Implement proper loading patterns for Google Maps JavaScript API

User story

As a real estate agent using the onOffice for WP-Websites Plugin, I am concerned about the current implementation of loading the Google Maps JavaScript API directly without a callback, as it may lead to race conditions and suboptimal performance. To ensure a more reliable and efficient integration, I seek the implementation of the correct loading patterns recommendet by Google for the Google Maps API.

To address this concern and align with best practices recommenden by Google, I propose the adoption of correct loading patterns for the Google Maps API.

Tasks

By implementing the correct loading patterns for the Google Maps JavaScript API, the onOffice for WP-Websites Plugin can enhance its performance, reliability and overall user experience, ensuring a seamless integration with Google Maps functionalities.

yeneastgate commented 10 months ago

@fredericalpers Below are some of my analyses about those ways "Load the Maps JavaScript API" I. Use "Dynamic Library Import"

  1. Advantage:
    • Only load required scripts

image

image

  1. Disadvantage:
    • Cannot inherit current source code.
    • Affect backward compatibility: Need to create mapID

https://github.com/onOffice-Web-Org/oo-wp-plugin/assets/104892108/5217dc77-d922-4660-a66b-2048a79b7eb5

=> Old users will have difficulty creating mapID

  1. Implement: We have implemented this solution in the branch https://github.com/onOffice-Web-Org/oo-wp-plugin/tree/proper-loading-of-google-maps-js-api-in-onoffice-plugin. You can test and review it.

II. Use "Direct Script Loading Tag"

  1. Advantage:

    • Can inherit current source code.
    • Easily add more callbacks according to Google's recommendations
  2. Disadvantage:

    • Performance: May slow down page load time if many libraries are loaded.
  3. Implement:

III. Use the NPM js-api-loader package: not suitable because it is not necessary to install additional packages

fredericalpers commented 10 months ago

@yeneastgate thank you, we will review this carefully. :)

fredericalpers commented 3 months ago

Due to the priority and relevance of other issues and projects, this issue will be postponed to v5.3