GLoader

Component ID

1277698

Component name

GLoader

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

The GLoader module gives easy access to the Google APIs and Libraries.
It will setup the HTML and JavaScript needed to load a Google API/Libraries, that can be loaded from the Google Loader.

Getting it to work

You need to set a Google API key before you can use the loader. Set this key in the GLoader Settings [admin/system/gloader].
Now you can add any API or library from your code.
gloader('maps', 2); // Load GMaps API version 2

Advanced loads

You can also utilize the supported options for each available API (see the options at Google Loader Developer Guide), by simply adding them in an array.
gloader('picker', 1, array('language' => 'en'));

How does it work?

The GLoader will insert the loads into the header before the page is created (during the hook_js_alter).
It will try to use the autoloading instead of the dynamic loading when possible, which according to google:

This allows you to reduce the load time in many cases by reducing the number of JavaScript requests that run at load time.

Why use GLoader

  • You don't have to handle the Google API key. The API key will only have to be entered once for all the modules using the GLoader.
  • Easy to use one liner, so you don't have to look up the correct URL everytime.
  • You do not have to worry about loading the same library more than once (assuming your other modules use the GLoader to load Google API and libraries).