GPT 4oooooo!


You can now use OpenAI's latest and most powerful language model, GPT 4o, with Slater AI. We've been testing GPT 4o this week and Slater AI's capabilities are better and faster than ever! Along with the new model, we implemented several improvements to Slater AI. Slater AI will now give more Slater and Webflow relevant answers since we give Slater AI contextual understanding (h/t tdlabs.ca). We also improved the messages parsing (h/t @jeffamcavoy).


Slater Sessions

Slater Sessions are back! In this Session, Witt breaks down the different flavors of Slater scripts.

video preview

Javascript 101: Loading Scripts

In keeping with the Slater Session, let's break down the different ways of loading Javascript in Webflow. Slater scripts can be loaded in one of two ways: loading a script (Simple Script) at the bottom of the DOM or dynamically adding a script (Smart Script) to the DOM on the DOMContentLoaded event. Here are the differences and implications of each approach:

1. Loading a Script at the Bottom of the DOM

Description:

  • You place your simple script <script> tags just before the closing </body> tag of your HTML document.

Pros:

  • Improved Initial Page Load: The browser can render the HTML content without waiting for the scripts to download and execute, which can speed up the initial page load time.
  • Deferred Script Execution: Since the script is at the bottom, it executes after the DOM has been fully parsed. This avoids blocking the rendering of the page.

Cons:

  • DOMContentLoaded Timing: If your script is large or the network is slow, the DOMContentLoaded event might be delayed because it waits for all scripts at the bottom to execute.
  • Less Control: You can't easily control exactly when the script starts executing, other than it being after the DOM is fully parsed.

2. Dynamically Adding a Script on DOMContentLoaded

Description:

  • You wait for the DOMContentLoaded event, then use JavaScript to create and append a <script> element to the DOM. This is how we handle the Smart Script.

Pros:

  • Precise Control: You have precise control over when the script is loaded and executed. This can be useful if your script depends on the DOM being fully available.
  • Non-blocking: Since the script is added after DOMContentLoaded, it does not block the initial HTML parsing and rendering.

Cons:

  • Slightly More Complex: This approach is slightly more complex to implement than simply placing the <script> tag at the bottom.
  • Initial Load Time: The script starts loading only after the DOMContentLoaded event, which can slightly delay the availability of the script.

Key Differences

1. Execution Timing:

  • Bottom of the DOM: The script executes as soon as the browser reaches the bottom of the HTML document.
  • DOMContentLoaded Event: The script starts loading and executing only after the DOMContentLoaded event fires.

2. Blocking Behavior:

  • Bottom of the DOM: If the script is large or slow to load, it can delay the firing of the DOMContentLoaded event.
  • DOMContentLoaded Event: The initial rendering and the DOMContentLoaded event are not blocked by the script, as it begins loading only after the DOM is ready.

3. Control:

  • Bottom of the DOM: Less control over the exact timing of script execution.
  • DOMContentLoaded Event: Greater control over when the script is added and starts executing.

Practical Considerations

We recommend you use the Smart Script as your default. It makes managing your Javascript effortless. Add the Smart Script to your global footer and then you can add files to Webflow pages, write Javascript, and handle Staging and Production code all from your Slater editor. Occasionally, you may run into special timing or scope considerations. In those cases, you can add a simple script to your project.

Does that all make sense? We hope so but let us know if you have any questions.


Your projects, supported by Slater

Before we go, we want to show a really cool GSAP project by Hunter Harralson @ pushrefresh.com. Beautiful work, Hunter!

Are you working on something worth sharing? Please do!

🤙 The Slater Team

If Slater helps you create better websites, please support the team behind it.

Welcome To Slater!

Slater resources, updates and community activity

Read more from Welcome To Slater!
video

You may recall that the original Slater had access controls for projects and files. We didn't want just anyone going in there and rewriting our Javascript. However, managing access for teammates became cumbersome (I even added a "god mode" to give myself access to any project or file). Since we generally trusted each other and never had issues, we decided to leave it out of the latest version of Slater. That said, we understand that some teams work differently, and maintaining control can be...

video

We're going to take a brief break from the regular newsletter format to celebrate the release of ask.edgarallan.com. Today, let's hear from Mason Poe, the Founder of Edgar Allan and Slater. I'm thrilled to announce the launch of ask.edgarallan.com and the start of a new conversation. We can all feel it: the web is changing in ways that seem both dramatic and, in a weird way, imperceptible. At times, it’s hard to know where to start exploring what could be next. Sometimes, when you think...

Our new Edgar Allan website, which we're launching next week 🤫, uses over 3,000 lines of code. It’s a bit unwieldy! To better support the new EA website and similar JavaScript-heavy projects, we’ve added slater_import. This feature allows you to write a function once and then reuse it across all the files in your project. You can see how to use it here. ⬇️ Not ready to watch the video? No problem. To import a file, simply start typing the name of the file you want to import and click on the...