Go Back
How to detect if a site loads React
Posted:
I recently needed a way to figure out if React was being loaded on various different pages of a site. The first script I found didn't work, which basically looked to see if React was attached to the window object.
However, I did find this script that does work.
if (Array.from(document.querySelectorAll("*")).some((e) => e._reactRootContainer !== undefined)) {console.log("React.js");}
What it can't determine is if there are multiple versions of React running on a page, which is something I would like to be able to detect, if that makes sense. Is that possible?