Advanced DOM scripting Dynamic Web Design techniques Part One DOM scripting in DETAIL CHAPTER 1 does IT right with best PRAC Tices

Source: Internet
Author: User

You ' re excited; Your client is excited. All are well. You ' ve just launched the client ' S latest website, and it ' s fantastic. You ' ve put in hours of sweat and tears, tweaking every little detail of the design-expanding menus, interactive Ajax, All the latest bells and whistles. It looks good, works perfectly, and everyone ' s partying. But a week later disaster begins. The client phones in a panic; It seems they ' ve been getting calls from some customers who can ' t get past the home page, and others is having  Problems with some aspects of the feedback form-but it works fine for you and the client. Other people has been calling and complaining that the site are taking too long to download each page, even though it Doesn ' t look like there's much on the page, and you barely notice the load time. To top it off, the client had found that Its search engine ranking have plummeted from number one to nowhere. Things is not good after all. But wheRe could you have gone wrong? Let's find out.

Best practices is accepted and tested models for the the-the-go-about should-doing. They ' re not necessarily the "the only" or "even the best", but they ' re the the "the" majority agrees things should is done. Most of the time, best practices is mentioned near the end of a book, and more as a reminder so once you ' ve learned Everyth ing and you ' re on your, there ' s actually a proper-to-do it. I ' m putting best practices up front, because I want-to-the-right direction before you learn anything new. There's no point in going-dark roads of frustration when there ' s already a well-lit road ahead.

Unobtrusive and progressive enhancement

Extensible hypertext Markup Language (XHTML), cascading Style Sheets (CSS), and Document Object model (DOM) script ing using JavaScript is the big three of web design. xhtml provides the semantic meaning in your document structure; CSS provides the positioning and style for your document layout; and DOM Scripting enhances your document ' s behavior and interaction. Did you catch that? I said DOM scripting enhances, not provides, your document ' s behavior and interaction. The Difference between "enhances" and "provides" are an important distinction. We ' ve all learned about xhtml,semantics, and validating we have documents so they conform to the specifications, and we AL L USE CSS to properly style we semantically marked up XHTML strict documents (do, don ' t?), But dom Scri Pting, the third piece, the one that makes things extra slick and gives your web Applications extra flare, can is an Obtrusive beast.

DOM scripting relies on JavaScript. If you search for "unobtrusive JavaScript" on the Web, you'll find a flood of different descriptions, but that's only Because unobtrusiveness needs to be considered everywhere. It's not a Band-Aid you can just the throw onto your code to do it all good. There ' s No unobtrusive object in JavaScript (Hmm ... maybe there could be?), and you can ' t download some  "Unob Trusive "Library to fix your code. Unobtrusiveness is only possible with proper planning and preparation in your Web application. It must is considered when interacting with both the User and the web Developer. Your scripts must be unobtrusive to the user and avoid unnecessary flashy and annoying features (something that gave JavaScript a bad rap in the past). Scripts must also be unobtrusive to allow the page and markup to continue to work, though maybe not as elegantly, without& nbsp Javascript. Finally, they must is  unobtrusive and easy to implement WIthin your markup, using ID and class hooks to attach behavior and provide a separation of the script from the markup . To Better understand unobtrusiveness, and the integration of DOM scripting, XHTML, and CSS, you need to consider the Outcomes in the situation we looked at previously and understand the basic principles and
Their application to your code.

Methodologies often hear about with unobtrusiveness is "progressive enhancement" and "graceful degradation." Browsers that lack certain features should receive a equally informational,yet altered, view of the same document by Usin G techniques that either enhance the document as technologies is available (progressive enhancement) or degrade the Docum ENT when they is missing (graceful degradation). These, concepts is often used interchangeably, but each embraces the idea is not all browsers is created Equal-and Not all browsers should is treated equally. Also, you shouldn "a low" quality service on everyone just to being able to cater to the lowest common denominator.

One of my favorite quotes about the necessity of progressive enhancement comes from Nate Koechley of Yahoo, who sums it up When describing browser support (http://developer.yahoo.com/yui/articles/gbs/gbs.html):

"Support does isn't mean that everybody gets the same thing. Expecting the users using different browser software to has the identical experience fails to embrace or acknowledge the Heterogeneous essence of the Web. In fact, requiring the same experience for all users creates a barrier to participation. Availability and accessibility of content should be we key priority. "

If you're using JavaScript in a-a-inhibits the "availability and accessibility of content," you ' re doing something Wrong.

At the same time, progressive enhancement doesn ' t necessarily mean an all-or-nothing approach to javascript. The problem is this, unlike most programming or scripting languages so you would run on your own dedicated servers Or computers, JavaScript is a interpreted language that runs within A web browser, so you won ' t has any control ove R the wide variety and mix of software, hardware, and operating systems your script would need to handle. To deal with the infinite combinations, you had to be careful and create behavioral enhancements based on the Capabi Lities of the browser and the available technologies, which could mean providing a degraded solution that still relies on Lesser parts of javascript or a solution that falls back on traditional, javascript-free methods.

I ll be stressing these ideas of unobtrusiveness, degradability, and progressive enhancement throughout the book, but I ' ll also say that I am by no means a zealot. I do realize this your sites do need to support browsers without standards-compliant features. In many cases, proprietary methods would also be required, but the trick was to go for the standards-compliant and Only fall back on the proprietary if necessary.

When working with DOM scripts and integrating them to your site, you should always write scripts
That is
Standards Compliant:future-proof your application and ensure that your Web application would
Continue to support newer and better browsers.
Maintainable:incorporate reusable and easily understood methods so, you and others can
Focus on the business task at hand, rather than rewriting the same things over and over.
Accessible:ensure that everyone can easily and efficiently access your information, even those
Without the script or JavaScript enabled.
Usable:something that works great in one situation but was hard to implement or replicate isn ' t
Going to is much fun the second or third time around. Usability applies to both the interaction
With the end user and the interaction with developers.

Advanced DOM scripting Dynamic Web Design techniques Part One DOM scripting in DETAIL CHAPTER 1 does IT right and best p Ractices

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.