Running the whole site through a CDN is also the modern thing to do and can help give your users an excellent experience. In this scenario, you cant use the CNAME. The DNS providers have a solution called ANAME or ALIAS, allowing you to point to the CDN endpoint on the root domain.
Why we are getting poor performance when we use ANAME/ALIAS records?
The ANAME or ALIAS is resolved by your DNS provider’s nameserver instead of by a recursive resolver (ISP, Google Public DNS, OpenDNS, or other) and this may lead to end-users being routed to a far-away CDN node and consequently getting a poor experience.
For example,
Imagine Thailand is an important market for your company, “yourdomain.com”. Logically, you work with a CDN that has a POP in Thailand. Your authoritative DNS provider has POPs in Hong Kong and Singapore, but not in Thailand.
The DNS server of an ISP in Thailand sends a query for “yourdomain.com” to your DNS provider and that query is routed to their Hong Kong POP. The authority’s nameserver in Hong Kong now resolves the ANAME/ALIAS, by sending a query to the CDN’s DNS server. The CDN’s DNS server sees a query coming in from Hong Kong and it hands out the IPs for the CDN POP in Hong Kong. As a result, people in Thailand visiting “yourdomain.com” get the content from the CDN PoP in Hong Kong (100 ms RTT) instead of from Thailand (30 ms RTT).