# Unobtrusive JavaScript

> general approach to the use of JavaScript in web pages

**Wikidata**: [Q2298909](https://www.wikidata.org/wiki/Q2298909)  
**Wikipedia**: [English](https://en.wikipedia.org/wiki/Unobtrusive_JavaScript)  
**Source**: https://4ort.xyz/entity/unobtrusive-javascript

## Summary
Unobtrusive JavaScript is a general approach to using JavaScript in web pages by separating behavior from structure and presentation. It emphasizes keeping JavaScript code out of HTML markup, improving maintainability and accessibility. This technique was popularized to enhance web development practices by promoting cleaner, more modular code.

## Key Facts
- **Instance of**: Programming language (related to JavaScript)
- **Aliases**: JavaScript discreto, UJS, جافا سكريبت المخفيه
- **Freebase ID**: /m/027y_zj (discontinued identifier)
- **Wikipedia title**: Unobtrusive JavaScript
- **Stack Exchange tag**: [ujs](https://stackoverflow.com/tags/ujs)
- **Wikipedia languages**: Available in Arabic, German, English, Spanish, Persian, French, Japanese, Korean, Russian, and Serbian
- **Microsoft Academic ID**: 198240166 (discontinued identifier)
- **Wikidata description**: General approach to the use of JavaScript in web pages

## FAQs
### Q: What is the main goal of Unobtrusive JavaScript?
A: The main goal is to separate JavaScript behavior from HTML structure and CSS presentation, improving code maintainability and accessibility.

### Q: How does Unobtrusive JavaScript differ from traditional JavaScript usage?
A: Unlike traditional methods where JavaScript is embedded directly in HTML, Unobtrusive JavaScript keeps scripts in external files, reducing clutter and enhancing separation of concerns.

### Q: Who popularized Unobtrusive JavaScript?
A: The approach was popularized by web development best practices, though specific creators are not attributed in the source material.

### Q: What are the benefits of using Unobtrusive JavaScript?
A: Benefits include improved code organization, better accessibility, easier debugging, and enhanced performance by separating concerns.

### Q: Is Unobtrusive JavaScript still relevant today?
A: Yes, the principles remain relevant as they align with modern web development practices like progressive enhancement and modular code.

## Why It Matters
Unobtrusive JavaScript is significant in web development as it addresses the need for cleaner, more maintainable code. By separating behavior from structure and presentation, it improves accessibility, reduces debugging complexity, and enhances performance. This approach was particularly influential in the early 2000s as web applications grew in complexity, and it laid the foundation for modern JavaScript frameworks and libraries. By promoting modularity and separation of concerns, Unobtrusive JavaScript helps developers build more robust and scalable web applications.

## Notable For
- **Separation of Concerns**: Pioneered the separation of JavaScript, HTML, and CSS, a core principle in modern web development.
- **Accessibility Advocacy**: Emphasized practices that improve web accessibility by keeping markup clean and semantic.
- **Maintainability**: Encouraged practices that make code easier to maintain and update over time.
- **Performance**: Improved performance by reducing inline JavaScript and promoting external script files.
- **Cross-Browser Compatibility**: Helped standardize JavaScript usage across different browsers.

## Body
### Origins and Philosophy
Unobtrusive JavaScript emerged as a response to the growing complexity of web applications in the early 2000s. The approach was driven by the need to separate behavior from presentation, a principle that became foundational in web development best practices.

### Technical Implementation
The technique involves:
- **External Scripts**: Placing JavaScript in separate files rather than inline with HTML.
- **Event Handling**: Using unobtrusive event handlers to attach behaviors to elements.
- **Semantic Markup**: Ensuring HTML remains clean and semantic, free from JavaScript dependencies.

### Impact on Web Development
Unobtrusive JavaScript influenced modern frameworks like React and Angular by promoting component-based architecture and separation of concerns. It also contributed to the rise of progressive enhancement, ensuring web applications remain functional even with disabled JavaScript.

### Legacy and Relevance
While specific implementations may vary, the core principles of Unobtrusive JavaScript remain relevant in contemporary web development. It continues to guide best practices for writing clean, maintainable, and accessible JavaScript code.

## References

1. Freebase Data Dumps. 2013
2. [OpenAlex](https://docs.openalex.org/download-snapshot/snapshot-data-format)