What the non-intrusive JavaScript is for:
1. Not everyone's browser supports JavaScript. Need to get everyone to see the whole content without having to execute code in the browser
You can use the app.
2. Some browsers run in a very strange way. For example, visually impaired people use screen readers, and some mobile phone users cannot use a
JavaScript's site.
3.JavaScript on different platforms, IE is the cause of this problem. You need to write a different browser based on what you don't
Event-handling code.
4. These event handlers will reference functions in the global namespace. If you want to integrate other class libraries with the same functions
Name, then it seemed troublesome.
5. These event listeners bind data structures and behaviors, which makes the code more difficult to maintain, extend, and understand.
Non-intrusive JavaScript (unobtrusive JavaScript) is a good practice for separating JavaScript code from markup. You can package all the required scripting code into a. js file. If you view the source code for the view, you will not see JavaScript code embedded in the tag. Even if you look at the HTML markup of the view rendering and you don't see any JavaScript code, the only trace left by the script is the <script> tag of one or more reference JavaScript files.
It follows the separation of concerns advocated by the MVC framework Design pattern. It implements the separation of content display (implemented by markup) and interaction behavior (implemented by JavaScript). Beyond that, there are other advantages to non-intrusive javascript. For example, keeping all script code in a separate downloadable file allows the browser to cache script files locally, improving the performance of the site.
Non-intrusive JavaScript