diff --git a/README.md b/README.md
index e1ec6b701d..fec45c80aa 100644
--- a/README.md
+++ b/README.md
@@ -49,37 +49,7 @@ The JavaScript SDK lets you track customer event data from your website and send
### Using CDN
-To integrate the JavaScript SDK with your website, place the following code snippet in the `
` section of your website.
-
-```javascript
-
-```
-
-
-
-> The above snippet lets you integrate the SDK with your website and load it asynchronously to avoid impacting the performance of your webpages.
+See [CDN installation](https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-javascript-sdk/quickstart/#using-cdn) for detailed steps.
To load SDK script on to your page synchronously, see the [**JavaScript SDK documentation**](https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-javascript-sdk/installation/#synchronous-loading).
diff --git a/packages/analytics-js/public/index.html b/packages/analytics-js/public/index.html
index 651e4b19f5..12a4144756 100644
--- a/packages/analytics-js/public/index.html
+++ b/packages/analytics-js/public/index.html
@@ -59,16 +59,28 @@
}
};
window.rudderAnalyticsMount = function() {
- if (typeof globalThis === "undefined") {
- Object.defineProperty(Object.prototype, "__globalThis_magic__", {
- get: function get() {
- return this;
- },
- configurable: true
- });
- __globalThis_magic__.globalThis = __globalThis_magic__;
- delete Object.prototype.__globalThis_magic__;
- }
+ (function() {
+ if (typeof globalThis === "undefined") {
+ var getGlobal = function() {
+ if (typeof self !== "undefined") {
+ return self;
+ }
+ if (typeof window !== "undefined") {
+ return window;
+ }
+ return null;
+ };
+
+ var global = getGlobal();
+
+ if (global) {
+ Object.defineProperty(global, 'globalThis', {
+ value: global,
+ configurable: true
+ });
+ }
+ }
+ })();
// Commented out SDK script addition
// as the build process automatically adds the script
diff --git a/packages/loading-scripts/src/index.ts b/packages/loading-scripts/src/index.ts
index 311e2ce017..2248d2cdf2 100644
--- a/packages/loading-scripts/src/index.ts
+++ b/packages/loading-scripts/src/index.ts
@@ -99,18 +99,28 @@ if (Array.isArray(rudderanalytics)) {
window.rudderAnalyticsMount = () => {
/* eslint-disable */
// globalThis polyfill as polyfill-fastly.io one does not work in legacy safari
- if (typeof globalThis === 'undefined') {
- Object.defineProperty(Object.prototype, '__globalThis_magic__', {
- get: function get() {
- return this;
- },
- configurable: true,
- });
- // @ts-ignore
- __globalThis_magic__.globalThis = __globalThis_magic__;
- // @ts-ignore
- delete Object.prototype.__globalThis_magic__;
- }
+ (function () {
+ if (typeof globalThis === 'undefined') {
+ var getGlobal = function () {
+ if (typeof self !== 'undefined') {
+ return self;
+ }
+ if (typeof window !== 'undefined') {
+ return window;
+ }
+ return null;
+ };
+
+ var global = getGlobal();
+
+ if (global) {
+ Object.defineProperty(global, 'globalThis', {
+ value: global,
+ configurable: true,
+ });
+ }
+ }
+ })();
/* eslint-enable */
window.rudderAnalyticsAddScript(
diff --git a/packages/sanity-suite/public/v3/index-cdn.html b/packages/sanity-suite/public/v3/index-cdn.html
index 9fda0446f7..7f731b82ba 100644
--- a/packages/sanity-suite/public/v3/index-cdn.html
+++ b/packages/sanity-suite/public/v3/index-cdn.html
@@ -81,16 +81,28 @@
}
};
window.rudderAnalyticsMount = function() {
- if (typeof globalThis === "undefined") {
- Object.defineProperty(Object.prototype, "__globalThis_magic__", {
- get: function get() {
- return this;
- },
- configurable: true
- });
- __globalThis_magic__.globalThis = __globalThis_magic__;
- delete Object.prototype.__globalThis_magic__;
- }
+ (function() {
+ if (typeof globalThis === "undefined") {
+ var getGlobal = function() {
+ if (typeof self !== "undefined") {
+ return self;
+ }
+ if (typeof window !== "undefined") {
+ return window;
+ }
+ return null;
+ };
+
+ var global = getGlobal();
+
+ if (global) {
+ Object.defineProperty(global, 'globalThis', {
+ value: global,
+ configurable: true
+ });
+ }
+ }
+ })();
window.rudderAnalyticsAddScript("".concat(sdkBaseUrl, "/").concat(window.rudderAnalyticsBuildType, "/").concat(sdkName), "data-rsa-write-key", "__WRITE_KEY__");
};
if (typeof Promise === "undefined" || typeof globalThis === "undefined") {
diff --git a/packages/sanity-suite/public/v3/index-local.html b/packages/sanity-suite/public/v3/index-local.html
index 447a493a1e..8baa8085f3 100644
--- a/packages/sanity-suite/public/v3/index-local.html
+++ b/packages/sanity-suite/public/v3/index-local.html
@@ -81,16 +81,28 @@
}
};
window.rudderAnalyticsMount = function() {
- if (typeof globalThis === "undefined") {
- Object.defineProperty(Object.prototype, "__globalThis_magic__", {
- get: function get() {
- return this;
- },
- configurable: true
- });
- __globalThis_magic__.globalThis = __globalThis_magic__;
- delete Object.prototype.__globalThis_magic__;
- }
+ (function() {
+ if (typeof globalThis === "undefined") {
+ var getGlobal = function() {
+ if (typeof self !== "undefined") {
+ return self;
+ }
+ if (typeof window !== "undefined") {
+ return window;
+ }
+ return null;
+ };
+
+ var global = getGlobal();
+
+ if (global) {
+ Object.defineProperty(global, 'globalThis', {
+ value: global,
+ configurable: true
+ });
+ }
+ }
+ })();
// window.rudderAnalyticsAddScript("".concat(sdkBaseUrl, "/").concat(window.rudderAnalyticsBuildType, "/").concat(sdkName), "data-rsa-write-key", "__WRITE_KEY__");
};
if (typeof Promise === "undefined" || typeof globalThis === "undefined") {
diff --git a/packages/sanity-suite/public/v3/index-npm-bundled.html b/packages/sanity-suite/public/v3/index-npm-bundled.html
index 7bc80d37e7..91bdba206f 100644
--- a/packages/sanity-suite/public/v3/index-npm-bundled.html
+++ b/packages/sanity-suite/public/v3/index-npm-bundled.html
@@ -95,16 +95,28 @@
src="https://polyfill-fastly.io/v3/polyfill.min.js?version=3.111.0&features=Symbol%2CPromise%2CglobalThis"
>