Google's John Mueller said on Twitter that GoogleBot currently will process the rel=canonical attribute on the initial fetch, not on the rendered version of the HTML. Pedro Dias picked this up while watching the JavaScript session at I/O.
He said "I don’t know if everyone’s seen this but there’s a very important point here regarding canonicals. And it’s the fact Google only checks canonicals on the raw HTML, not the rendered one." Why is this important, he said you should "make sure your server doesn’t output canonical placeholders that are replaced on render."
John Mueller confirmed this by saying "We (currently) only process the rel=canonical on the initially fetched, non-rendered version."
We (currently) only process the rel=canonical on the initially fetched, non-rendered version.
— John ☆.o(≧▽≦)o.☆ (@JohnMu) May 10, 2018
Eric Wu noted a site doing it wrong:
You can insert it, that doesn't mean it does anything :)
— John ☆.o(≧▽≦)o.☆ (@JohnMu) May 11, 2018
So make sure to keep this in mind when implementing canonical tags.
Forum discussion at Twitter.