Non-intrusive JavaScript

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.