Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2d05217

Browse filesBrowse files
fix: add loading=async to the urls with callbacks (#822)
1 parent 2e2b8c4 commit 2d05217
Copy full SHA for 2d05217

File tree

Expand file treeCollapse file tree

2 files changed

+11
-8
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-8
lines changed

‎src/index.test.ts

Copy file name to clipboardExpand all lines: src/index.test.ts
+10-7Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ afterEach(() => {
2525
});
2626

2727
test.each([
28-
[{}, "https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback"],
28+
[
29+
{},
30+
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&loading=async",
31+
],
2932
[
3033
{ apiKey: "foo" },
31-
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&key=foo",
34+
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&loading=async&key=foo",
3235
],
3336
[
3437
{
@@ -38,23 +41,23 @@ test.each([
3841
language: "language",
3942
region: "region",
4043
},
41-
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&key=foo&libraries=marker,places&language=language&region=region&v=weekly",
44+
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&loading=async&key=foo&libraries=marker,places&language=language&region=region&v=weekly",
4245
],
4346
[
4447
{ mapIds: ["foo", "bar"] },
45-
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&map_ids=foo,bar",
48+
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&loading=async&map_ids=foo,bar",
4649
],
4750
[
4851
{ url: "https://example.com/js" },
49-
"https://example.com/js?callback=__googleMapsCallback",
52+
"https://example.com/js?callback=__googleMapsCallback&loading=async",
5053
],
5154
[
5255
{ client: "bar", channel: "foo" },
53-
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&channel=foo&client=bar",
56+
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&loading=async&channel=foo&client=bar",
5457
],
5558
[
5659
{ authReferrerPolicy: "origin" },
57-
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&auth_referrer_policy=origin",
60+
"https://maps.googleapis.com/maps/api/js?callback=__googleMapsCallback&loading=async&auth_referrer_policy=origin",
5861
],
5962
])("createUrl is correct", (options: LoaderOptions, expected: string) => {
6063
const loader = new Loader(options);

‎src/index.ts

Copy file name to clipboardExpand all lines: src/index.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ export class Loader {
369369
public createUrl(): string {
370370
let url = this.url;
371371

372-
url += `?callback=__googleMapsCallback`;
372+
url += `?callback=__googleMapsCallback&loading=async`;
373373

374374
if (this.apiKey) {
375375
url += `&key=${this.apiKey}`;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.