↩️ Undo better


Do you get confused when undoing (cmd + z) in Slater? We auto-format your code on save. The auto-formatting updates your code, and those updates get pushed into the undo stack. You can now improve your workflow by formatting the code when you choose—not just on save.

To gain more control over when your code formats:

  • Turn off auto-format code in the Code Editor Settings
  • Use cmd + shift + f to format your code

We added a handful of other improvements:

  • Console logs and debuggers are now automatically stripped out of production files. If you need to debug on production, unselect the “minify production files” checkbox in Project Settings.
  • We improved the experience when multiple users are in the same project.
  • Improvements to the new CSS-capable smart script
  • Other UI fixes and improvements

We are now working on a new user type for your clients. This “hosting only” plan will be cheaper, $5/mo, and allow your clients to own their JavaScript. As always, you will have access to update the code of transferred projects unless the new owner explicitly removes you from the team.

Have you transferred a Slater project? Do you want any updates to support code handoff?

Javascript 101: Good Functions

Are you using slater_import yet? It's very useful but you need to know how to use it. It isn't obvious like clicking a button. Let's give a brief recap on how to use slater_import:

  • Create a file for import functions. Don't connect the file to any Webflow pages.
  • In another file that is connected to a Webflow page(s), start typing the file name for the file you want to import.
  • Click on the autocompletion.

In the example below, I start typing Global and click on the name of the file, Global Functions.

Ok, now you have the ability to import functions across your project.

Let's now discuss how to write a good function:

1. Use Descriptive Names

Choose clear, descriptive names that explain what the function does. Example: calculateTotalPrice() instead of calc().

2. Follow the Single Responsibility Principle

Each function should do one thing and do it well. If a function is doing multiple things, consider breaking it into smaller functions.

3. Keep Functions Short

Aim for functions that are 20-30 lines or less. Longer functions are harder to understand and maintain.

4. Use Parameters Wisely

Limit the number of parameters (ideally 3 or fewer). Use object parameters for functions that require many inputs.

5. Return Early

Use early returns to handle edge cases and simplify logic.

function divide(a, b) {
if (b === 0) {
return "Cannot divide by zero";
}
return a / b;
}

6. Use Arrow Functions for Short, Simple Functions

They provide a concise syntax for simple functions.

const double = (x) => x * 2;

7. Document Your Functions

Use Slater Documentation to document your imported file. Add comments to your file to describe what the function does, its parameters, and return value.

8. Handle Errors Gracefully

Use try-catch blocks or return error objects for error handling.

try{
// Block of code to try
}
catch(Exception e){
// Block of code to handle errors
}

Remember, these are guidelines, not strict rules. The key is to write functions that are easy to understand, maintain, and reuse.

Happy coding!

Your projects, supported by Slater

🧐

🤙 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 preview

Last week, we announced that CSS updates were on the way—and now they're here! You can now generate CSS files just as quickly and easily as JS files. In the video below, we give a quick demo of the new functionality. If you have a Smart Script loaded in your project, you can instantly add CSS. In the demo, we also show how to add CSS in the Webflow designer. Give it a try and let us know what you're building! Community Library 🖍️ Text Highlight ColorCSS code for custom text selection. 🅰...

Do you use Slater for CSS? CSS support in Slater has always been somewhat of an afterthought—JavaScript is our love language! But sometimes, you need a simple way to add CSS to your project. Maybe you want to write a complex grid or use a CSS property that Webflow doesn't support. That's why we've decided to make CSS a first-class citizen. We considered launching the new CSS functionality today, but we want to test it a bit more. Expect it early next week. To prepare for the launch, let's...

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...