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.
Organize your project by responsibility to make your codebase easier to manage and scale:
globals: Site-wide behaviors (e.g., navigation helpers, focus rings)utils: Pure helper functions reusable across files (use slater_import to reuse)components: Element-scoped features (e.g., accordions, modals, sliders)pages: Page- or template-specific code (e.g., code for /pricing)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
| 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.