I’m having trouble with a Google document that I embedded into my website. Sometimes I get this JavaScript error in the browser console:
Uncaught ReferenceError: DOCS_timing is not defined
at pub?
I created the embed link through Google Docs using their standard sharing options. The URL format I’m using looks like this (with the dots representing the actual document ID):
https://docs.google.com/document/d/.../export?format=pdf
Here’s the iframe code I’m using in my React component:
<iframe
title={"Resume"}
src={documentUrl}
onLoad={handleLoadComplete}
style={frameStyles}
allow="picture-in-picture fullscreen">
</iframe>
The document displays correctly most of the time, but these console errors appear randomly. Has anyone encountered this issue before?
yea, it’s super annoying! google docs has this bug where it tries to load tracking scripts in iframes and fails. you can catch em with window.onerror or wrap your iframe with an error boundary. don’t worry too much tho, they’re just cosmetic errors!
Had this exact issue two years ago building a document portal. DOCS_timing errors happen when Google’s viewer tries loading performance scripts that can’t access cross-origin iframes. Fixed it by adding sandbox="allow-scripts allow-same-origin" to my iframe attributes. Also switch to the preview URL: https://docs.google.com/document/d/.../preview instead of export. Preview handles iframes way better than export URLs. You’ll probably still see random errors in dev mode, but they won’t break anything in production. The randomness is likely Google’s CDN serving different script versions.
I hit this exact error about six months ago on a client project. The DOCS_timing error happens when Google’s internal scripts can’t access timing variables in embedded contexts. I’ve noticed it pops up way more with export format URLs than standard embed URLs. Skip the export format and use Google’s standard embed URL instead: https://docs.google.com/document/d/.../edit?embedded=true. Fixed it completely for me. Export formats are built for direct downloads, not iframe embedding - that’s why Google’s timing scripts can’t initialize properly.