Search code examples
javascriptractivejs

How to organise RactiveJS code


I struggle to find any suggestions how to organize RactiveJs code.

Currently I just put RactiveJs code to the bottom of the page. It was okay till my scripts were small. But the bigger they are the more problem it causes. I'm considering moving the RactiveJs code to separate js files, may be using some pattern (Module?).

Are there any guidelines in this regards?


Solution

  • There is a spec for component-per-file: https://github.com/ractivejs/component-spec/ and there are loaders that allow you to incorporate them into the page.

    However, Ractive doesn't force you to use this pattern. You are free to experiment whatever convention works for you.