Search code examples
javascriptgoogle-app-enginecdn

About CDN. Where do the methods work? Client? Sever?


I am Japanese and not good at English sorry.

I was looking at this doc.

https://developers.google.com/docs/api/quickstart/js

<script async="" defer="" onload="this.onload=function(){};handleClientLoad()" onreadystatechange="if (this.readyState === 'complete') this.onload()" src="https://apis.google.com/js/api.js"></script>

I thought we can't use google api on client side.

Because it needs server such as node.

But in this way we can use gapi() method only in client side.

Is that mean method from CDN works on server?

Not client side?


Solution

  • Briefly: The Content Delivery Network, delivers the script to the client. Then all methods from that library run on the client side.


    More verbose: When you request a website from your browser, it executes your code on your side (Client), when it gets to a line where it needs to fetch some content from a CDN, it makes the request to the CDN (network of servers) and receives what the CDN delivers. The received source, if called in any subsequent lines will be executed in your browser (Client-side)