readthedocs.org
readthedocs.org copied to clipboard
'$ is not defined' in readthedocs-doc-embed.js
Details
- Read the Docs project URL: https://readthedocs.org/projects/ddev/
- Build URL (if applicable): https://readthedocs.org/projects/ddev/builds/17381772/
- Read the Docs username (if applicable): https://readthedocs.org/profiles/ddev/
Expected Result
Normal processing without js errors. (When I run mkdocs serve
and view the same site I do not have js errors in console.)
Actual Result
In console:
Uncaught ReferenceError: $ is not defined
at Object.get (readthedocs-doc-embed.js:1:22772)
at Object.init (readthedocs-doc-embed.js:1:20826)
at HTMLDocument.e (readthedocs-doc-embed.js:1:34016)
Is there some need to inject jquery or something for RTD? I don't remember seeing this before.
Hi, I think the material theme doesn't include jquery, so you need to add it https://www.mkdocs.org/user-guide/configuration/#extra_javascript.
We are planning to inject jquery conditionally https://github.com/readthedocs/readthedocs.org/pull/9359.
Thank you very much @stsewd - that solved that problem. Now if you'd just remind me how to get rid of the ethicalads.min.js crash "Error: No ad placements found". (I already unchecked the ads checkbox.)
ethicalads.min.js:1 Uncaught (in promise) Error: No ad placements found.
at b (ethicalads.min.js:1:12013)
at ethicalads.min.js:1:13123
@rfay where are you getting that error? Looks like you are testing the changes in a forked project, so not sure where to find it.
Also, you can enable builds from PRs https://docs.readthedocs.io/en/stable/pull-requests.html for your project, so you don't need to use a fork to test things.
That's in the console on https://test-ddev.readthedocs.io/en/latest/, which is being built from https://github.com/rfay/ddev/tree/20220707_docs2,, build is https://readthedocs.org/projects/test-ddev/builds/17382495/
(And thank you!)
@davidfischer may have more information about that error.
This definitely looks like a jquery should be there but isn't error.
@davidfischer thanks for looking at this. I added jquery, got past the original issue. Now javascript errors out with the "ethicalads.min.js:1 Uncaught (in promise) Error: No ad placements found" as described in https://github.com/readthedocs/readthedocs.org/issues/9414#issuecomment-1177989360
I assume that's an RTD problem right? I remember seeing it before long ago, don't remember a solution.
Got it. I was confused.
I assume that's an RTD problem right? I remember seeing it before long ago, don't remember a solution.
Ahh. As you may know, RTD is funded with advertising and our ad client throws this error (probably should just be a warning) if there's nowhere to put an ad on the page. Are you seeing this on a public URL (eg. something.readthedocs.io
) or locally? I saw you were using make serve
(a local docs build on your machine, I presume?) but our ad client shouldn't be injected for a local build.
Thanks @davidfischer - It's a public RTD URL and details are in https://github.com/readthedocs/readthedocs.org/issues/9414#issuecomment-1178068130 - you can easily see it yourself.
See the browser js console (chrome) on https://test-ddev.readthedocs.io/en/latest/, which is being built from https://github.com/rfay/ddev/tree/20220707_docs2,, build is https://readthedocs.org/projects/test-ddev/builds/17382495/
Got it. This shouldn't be logged as an error. I should be able to release a fix in a day or two.
Awesome, thanks @davidfischer
@stsewd this problem is solved since our js file auto-loads jQuery now, right? This work was done in https://github.com/readthedocs/readthedocs.org/pull/9861
yeah, the original issue reported here should be fixed. For the other issue please subscribe to https://github.com/readthedocs/ethical-ad-client/pull/130.