Sunday, May 19, 2024
62
rated 0 times [  65] [ 3]  / answers: 1 / hits: 34719  / 13 Years ago, mon, december 5, 2011, 12:00:00

What is the difference between obtrusive and unobtrusive javascript - in plain english. Brevity is appreciated. Short examples are also appreciated.


More From » unobtrusive-javascript

 Answers
23

I don't endorse this anymore as it was valid in 2011 but perhaps not in 2018 and beyond.



Separation of concerns. Your HTML and CSS aren't tied into your JS code. Your JS code isn't inline to some HTML element. Your code doesn't have one big function (or non-function) for everything. You have short, succinct functions.



Modular.
This happens when you correctly separate concerns. Eg, Your awesome canvas animation doesn't need to know how vectors work in order to draw a box.



Don't kill the experience if they don't have JavaScript installed, or aren't running the most recent browsers-- do what you can to gracefully degrade experience.



Don't build mountains of useless code when you only need to do something small. People endlessly complicate their code by re-selecting DOM elements, goofing up semantic HTML and tossing numbered IDs in there, and other strange things that happen because they don't understand the document model or some other bit of technology-- so they rely on magic abstraction layers that slow everything down to garbage-speed and bring in mountains of overhead.


[#88739] Sunday, December 4, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jazmyne

Total Points: 503
Total Questions: 102
Total Answers: 99

Location: Svalbard and Jan Mayen
Member since Sun, Sep 25, 2022
2 Years ago
;