Created
March 16, 2024 00:41
-
-
Save learyjk/0f4ea905af2bb7412d3718fd12974d9b to your computer and use it in GitHub Desktop.
Staging vs. Production Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const currentDomain = window.location.hostname; | |
let scriptElement = document.createElement('script'); | |
scriptElement.type = 'text/javascript'; | |
if (currentDomain === 'staging.webflow.io') { | |
// staging | |
scriptElement.src = 'http://127.0.0.1/index.js'; | |
} else if (currentDomain === 'www.example.com') { | |
// production | |
scriptElement.src = 'https://cdn.jsdelivr.net/npm/@account-name-here/[email protected]/dist/location.js'; | |
} | |
// Append the script element to the document head | |
document.head.appendChild(scriptElement); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment