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

The team behind Slater would like to wish you a Merry Christmas and a happy New Year! 🎄🎅🎁 Get the Santa ASCII art: https://slater.app/projects/11431/pages/27608 Happy coding! 🤙 the Slater Team If Slater helps you create better websites, please support the team behind it. Become a Pro Slater User

Earlier this year, we built figdam.com. It is currently used by several of our clients to host files and watermark PDFs. We’d like to bring this file hosting functionality to Slater users. With that in mind, where do you currently store files that Webflow doesn’t support? Would this feature be useful to you? What file hosting features do you need? Let us know. JS 101: File types File storage? Javascript? Let's consider all of the different file types that you could host and then retrieve and...

Hi, Just a reminder that Kendra and Mason will be hosting an EA Office Hours Zoom this Friday, the 13th (spooky…) to chat about topics relating to Chapter 1: Sales for Creative Types. Sign up if you can make it, and bring your questions. Let’s get past any lingering sales ick together. Register to join us this Friday, 12/13 here. Also, if you can’t make it this week, we’re thinking about doing it again next Friday, 12/20 as well, if anyone is game? To ring in the holiday break, we’ll chat...