University of Central Florida (UCF) COP2500 Concepts in Computer Science Final Practice Exam

Disable ads (and more) with a membership for a one time $4.99 payment

Question: 1 / 85

When developing unobtrusive JavaScript, how should the JavaScript be organized?

Inline within HTML

Stored in a script tag

Stored in an external file with a .js extension

The most effective way to organize unobtrusive JavaScript is by storing it in an external file with a .js extension. This approach promotes a clear separation of concerns, where HTML is used for structure, CSS is used for styling, and JavaScript is reserved for behavior.

By placing JavaScript code in external files, you enhance maintainability and reusability, as the same script can be linked to multiple HTML documents without duplication. This organization also allows for better caching by web browsers, leading to improved performance as the browser can store the JavaScript file and reduce load times on subsequent visits. Additionally, using external files helps keep the HTML markup clean and more readable, which is essential for collaborative projects and long-term code management.

Furthermore, this practice aligns well with unobtrusive JavaScript principles, as it minimizes direct interaction with HTML elements and encourages the use of event listeners and other techniques to add functionality without cluttering the markup. This results in a more accessible and semantically correct structure, enhancing both user experience and search engine optimization.

Get further explanation with Examzify DeepDiveBeta

Embedded in CSS files

Next

Report this question