I am in the process of developing a section of my website that will utilize a moderate amount of JavaScript, and I am striving to write it in the most efficient way possible. I am transitioning from a mindset rooted in JS 2010 to one more aligned with 2016.
At this stage, there is no need for a framework like Angular 2. Therefore, I have opted for Webpack and Typescript 1.8 with ES2015+.
On the server-side, I am working with ASP.NET MVC 5, and my approach here mirrors the way I construct apps on the server: heavily relying on Dependency Injection.
Applying a similar philosophy to the client side led me to create the following structure:
export class Match {
// properties and methods defined here
}
All the selectors are included in the class through injection. This methodology results in a loosely coupled design (aside from JQuery), but I am unsure if this level of separation is excessive.