Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'ve been reading articles such as this one that indicates web development has

ID: 646872 • Letter: I

Question

I've been reading articles such as this one that indicates web development has evolved to use JS frameworks. Where I work, we have a massive website with many existing web applications that are already established and are server side heavy.

One article I read said that the DOM manipulation/jQuery method leads to unmaintanable spaghetti code, and that you should strive to use a JS MV* framework. However, sometimes I just have a fairly simple list of items generated from the server; something like:

<div class=shower data-id=1>show</div>
<ul><li class=hider data-id=1>one</li></ul>
//js
$(".shower").on("click", function () {
    $(".hider[data-id=" + $(this).data("id") + "]").show();
});
...and that would pretty much be the extend of the JS on that page. According to the MV* framework disciples, the need to reference specific classes or attributes in the JS is a problem and models should be used instead. However, it seems like overkill to include a massive library for creating rich applications to handle some fairly trivial DOM manipulation and animations.

Is there a JS framework in existence that bridges the gap between complete front-end stack frameworks and tightly coupled HTML/JS? If not, how could I write such code to avoid this coupling?

Additionally is there any reason to push strongly for making the switch to such a framework for established server-heavy applications (especially in cases where we have to support JavaScript being turned off)?

Explanation / Answer

The author of the article you linked seems to have forgotten about server-side HTML generation completely. You don't need all that JS ceremony to create a data-driven web page; the JS is there to augment the page, not generate it.

That said, none of these JS frameworks is all that large. "Massive library" is a mischaracterization. I suspect that if you make the attempt to write such code to avoid tight coupling, you'll be reinventing Backbone/Ember/Angular anyway.

If you're genuinely worried about the library size, use Resig's Micro-Templating, which weighs in at about thirty lines of javascript. Alternatively, you can get a custom-tailored recommendation for a JS framework at one of the links below.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote