Sage 10 and JS routing

Hi all!

On Sage 9 we have js-dom-router out of the box, which works perfectly, so I was wondering if it was excluded from Sage 10 maybe because there was a better approach/practice/pattern for executing scripts on certain routes.

Is it still js-dom-router the way to go? If so, is there a simple guide for integrating it with Sage 10?

Our current recommendation is to just write JS scripts that check to see if they should be run (i.e. “Does this class exist on this element?”). That’s essentially all that the router did, but this has the advantage of making the process less complex and more modular: With this approach it’s much easier to separate scripts in to separate files for improved performance if necessary.

If you want to replicate the template-based activation of the old router, you can always do something like:

if (document.body.classList.contains('template-name') {

Awesome, thank you @alwaysblank!

This topic was automatically closed after 42 days. New replies are no longer allowed.