↩️ 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!

👋, In August, we launched a novel approach to a marketing site with ask.edgarallan.com. Since then, we've been focused on determining whether we built a winner or a loser by refining our data analytics capabilities. So far, the results look promising: check out this update. Alongside ask.ea, we’re also enhancing our data analytics for Slater.app. What does that mean? Over the next several months, we’ll be rolling out updates based on your feedback and user data. Stay tuned—we’ll share our...

We’re taking a break from our usual JavaScript content to share some exciting news: Edgar Allan has released a new book, How to Grow & Scale Your Business With Webflow. Created in collaboration with Webflow, this book is a must-read for anyone building a business with Webflow. Filled with insights from 3x Agency of the Year winner Edgar Allan, it’s a playbook for individuals, pro-lancers, and small agencies growing alongside the revolutionary site-building platform. For our Slater users, we...

Slater now has 7389 users. 2060 of you haven't created a file yet. 😱 These numbers got us thinking – we want to make Slater easier and more helpful to all #nocode developers.We’d love to hear from you: Did you find it challenging to get started with Slater? Are there specific areas where you could use more guidance? Do you use JavaScript often in your Webflow projects? Or is Slater your first time exploring custom code? What would help you feel more confident writing JavaScript in Slater? Are...