More Slater Scripts πŸ“š


πŸ‘‹,

​

We pushed up a handful of updates yesterday. Quality of life improvements, bug fixes, and more Slater scripts!

Slater still works the same, but now you have more flexibility in how your JavaScript is loaded in your Webflow project. If the Slater Single Script is working for you, feel free to skip the details.

The details: Slater has two types of projects, connected and unconnected, and manages two environments, staging and production. Sometimes you may need more control over the timing or scope of your JavaScript.

Connected vs. Unconnected Projects

The Slater Single Script is a connected project that manages staging and production environments. It uses JavaScript's dynamic import to load the correct JavaScript file on the corresponding Webflow page. With the Slater Single Script, you can add, update, or remove files all from Slater without needing to publish on Webflow. However, you may encounter an issue if your file needs a global scope. (I have only seen this be an issue if you added an External Script.)

If you need global scope, you can add a single file using the new Slater scripts.

Staging vs. Production Environments

Slater allows you to make updates to the staging environment and push to production when your JavaScript is ready. Again, you don't need to publish on Webflow to save your changes. To load the correct environment file, Slater uses the DOMContentLoaded event.

If you need to load your JavaScript differently, you can now add a simple staging or production script.

​


​
Last week, we promised a Slater Session video, but work at Edgar Allan got in the way! (We'll get that video for you soon.) Want to know what the team is working on besides Slater?

​@witt is working on an AI experience for a VC clients and edgarallan.com.

Pabz is building a Wes Webflow app.

​@kevin is designing the Wes Webflow app.

​@jared is kicking off a project with a Series C startup.

​@mason is developing business for Edgar Allan (EA).

​


​

Javascript 101: JS Import

JavaScript imports are a fundamental aspect of modular programming in JavaScript, allowing developers to organize code into reusable and maintainable modules. There are two types of imports in JavaScript: static imports (using the import statement) and dynamic imports (using the import() function). Since we use dynamic imports in Slater, we'll focus on them.

Dynamic imports allow you to load modules asynchronously, meaning you can import files only when they are needed, rather than loading them all at once. This can improve performance, especially in large applications where loading all modules upfront may not be necessary or desirable.

Here's an example of what the Slater Single Script looks like:

// This file was generated by Slater.app - Loblolly​
​
​
// Global -> ​
import('https://slater.app/5348/9939.js?v=198015')
​
​
// About -> ​
{
let pages = ["about"];
let paths = window.location.pathname.split('/')
let path = paths[paths.length - 1]
let itemPath = paths[paths.length - 2]
if (pages.includes(path) || pages.includes('detail_' + itemPath) || pages.includes(itemPath + '/item')) import('https://slater.app/5348/9938.js?v=648512');
}

In this example:

  1. The global file (https://slater.app/5348/9939.js) is loaded on every page.
  2. The about script (https://slater.app/5348/9938.js) is loaded only on the "about" page.

Dynamic imports can improve performance because you load only the code you need for the current page or feature. Advanced users can also split code into separate modules, export functions and variables from those modules, and import the exported functions and variables into other files as needed. This modular approach can make code easier to maintain and reuse.

A potential downside of dynamic imports is that they add network requests, so an excessive number of files can impact load times, especially in low-bandwidth or high-latency environments.

So, that's imports. What do you want to learn about next?

Happy coding!

​

πŸ€™ The Slater team


​

πŸ™ If Slater helps you create better websites, please support the team behind it.

​
​
1295 Canyon View Rd, Midway, UT 84049
​Unsubscribe Β· Preferences​

​

Welcome To Slater!

Slater resources, updates and community activity

Read more from Welcome To Slater!
photo

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

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