269
Views
4
Comments
How to add CDN

Hello,

I want to add CDN on-page Like:- 

<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB41DRUbKWJHPxaFjMAwdrzWzbVKartNGg&callback=initMap&v=weekly" defer></script >

Where the key of that particular API is dynamic for users is there any way to add this google matrix API CDN on the page 


I already used this on-page ready and initialize but did not load the full CDN script:-

var scriptNode = document.createElement('script'); scriptNode.src = ""; 

scriptNode.async= "async"; 

scriptNode.defer = "defer" ;

document.getElementsByTagName('head')[0].appendChild(scriptNode); 

2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi Gourav,

Refer to this post: /forums/how-to-load-JavaScript-file-in-reactive-application

I hope this helps you!


Kind regards,

Benjith Sam

2024-07-12 05-57-50
Gourav Shrivastava
Champion

Hello,

This post suggests adding a whole js script in the service studio this is not the right way to use any CDN, it also makes a web page slow and we can't get the latest code changes on that script.

2020-05-27 13-33-29
Roxane Sancho y Fran

Hello,

Did you find a solution? I have the exact same issue and I don't want to add the whole script to my application for obvious reasons.

Regards,

Roxane

UserImage.jpg
Mark Collins

Searching for the same functionality reference the cdn and not downloading the js and adding it as a script file.  Did you ever get an answer?

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.