Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

ClientResources.RequireScript - Possible to use async or defer?

$
0
0

I've created a Google Maps block for usage on my website.

At the top of the block I have something like this:

@{
    var clientScript = string.Format("https://maps.googleapis.com/maps/api/js?key={0}&callback=initMap", Model.ApiKey);
    ClientResources.RequireScript(clientScript).AtFooter();
}

And then in my layout I have this:

@Html.RequiredClientResources("Footer");

This is working.  However, Google recommends adding `async` and `defer` to the script tag for Google Maps, like so:

<script src="https://maps.googleapis.com/..." async defer></script>

How can we instruct Episerver to inject async and defer attributes on the script tag which is output?


Viewing all articles
Browse latest Browse all 9076

Trending Articles