Statechart extension for scalable JavaScript application