Slater.app CMS

Best Practices for Organizing JavaScript in Your Slater Project

Learn how to structure your Slater project for maintainability, performance, and team collaboration. This guide covers recommended directory layout, usage of slater_import, and key patterns for sharing code and avoiding common pitfalls.

Organizing your JavaScript codebase in Slater helps improve readability, maintainability, and development speed. This article outlines recommended structures, import strategies, and best practices for Slater projects.


Recommended Project Structure

Organize your project by responsibility to make your codebase easier to manage and scale:

slater_import: Importing JavaScript

Use slater_import to import JavaScript files into your project. Create helper files for reusable functions. To reuse the functions:

The import will be auto-added to your file. It will look something like this: slater_import('/project/111/page/111.js') // Import Slater Import Test.js.

See Slater Imports introduction

Sharing Functions Across Files

Frequently Asked Questions

Question Answer
Should large files be split? Prefer many small, scoped files for easier testing and reasoning.
How to prepare for team handoff? Document each page with Slater Documentation (in the Tools panel of the editor).

Proper organization and following these conventions will help your Slater projects scale smoothly and avoid common pitfalls.