OpenEugene / little-help-book-web

Human service resource guide powered by White Bird Clinic
MIT License
6 stars 4 forks source link

Bringing the HTML out of homepage.js and using a function to hide and show it on the page when buttons click #99

Closed ArthurSmid closed 3 years ago

ArthurSmid commented 3 years ago

Something that came to mind, thinking about the mobile intro screens, while reading this section on

Maintainability

Loose Coupling

-- Quotes from pages 1039 to 1041 of JavaScript for Web Developers, by Matt Frisbie -- https://www.wiley.com/en-us/exportProduct/pdf/9781119366447)

"One of the most common types of coupling is HTML/JavaScript coupling. ... Generally speaking, you should avoid creating large amounts of HTML in JavaScript. This, once again, has to do with keeping the layers separate and being able to easily identify the source of errors."

"When JavaScript is used to insert data, it should do so without inserting markup whenever possible. Markup can typically be included and hidden when the entire page is rendered such that JavaScript can be used to display the markup later, instead of generating it. Another approach is to make an Ajax request to retrieve additional HTML to be displayed ..."

"Decoupling HTML and JavaScript can save time during debugging by making it easier to identify the source of errors, and it also eases maintainability: changes to behavior occur only in JavaScript files, whereas changes to markup occur only in rendering files."