When working with Webflow projects, it's important to manage your script code correctly for both staging and production environments. This guide explains how to use the Slater smart script to automatically handle these environments without manually switching code.
The Slater smart script provides a seamless way to manage your scripts based on the environment:
Here is an example of the Slater embed smart script:
<!--🤙 https://slater.app/1.js--><script>document.addEventListener("DOMContentLoaded", function() { function loadWebflowProject(e){ let t=document.createElement("script"); t.setAttribute("src",e), t.setAttribute("type","module"), document.body.appendChild(t), t.addEventListener("load",()=>{ console.log("Slater loaded Webflow Project.js: https://slater.app/1.js 🤙") }), t.addEventListener("error",e=>{ console.log("Error loading file",e) }) } let src=window.location.host.includes("webflow.io") ? "https://slater.app/1.js" : "https://assets.slater.app/slater/1.js?v=1.0"; loadWebflowProject(src);})</script>
By using the Slater smart script, you can streamline your Webflow project management, ensuring that the correct scripts are loaded for each environment. This approach minimizes errors and simplifies the development process.