Build your professional network on facebook via our app Go to app
 
 
Posted in Community :

Lightweight JavaScript

 
Industry : Technology Consulting Functional Area : New Technologies
Activity:  0 comments  57 views  last activity : 07 06 2010 20:18:04 +0000
Share
 
 
 

One of the most important things to keep in mind when writing JavaScript for the Web is to make it unobtrusive, since You cannot rely on JavaScript being available.

Sadly, there are many developers who do not seem to spend any energy at all on considering how to do that. Instead they choose to blindly forge ahead and assume that everybody who comes visiting will have full support for JavaScript and use a mouse.

Luckily there are a number of web developers who advocate unobtrusive JavaScript. One of the most noticeable ones is "Chris Heilmann", who talks a lot about it in his book Beginning JavaScript with DOM Scripting and Ajax. Recently Chris held a workshop on the subject, and while preparing his materials for the workshop he defined "The seven rules of Unobtrusive JavaScript"

Here are the seven rules mentioned for you:

Do not make any assumptions: Don’t expect JavaScript to be available, and don’t expect the intended markup to be there.

Find your hooks and relationships: Examine the HTML you are working with to find the best way of letting your script interact with it.

Leave traversing to the experts: When possible, let CSS take care of finding the element you want to change.

Understand browsers and users: Don’t deviate too far from the way browsers work and how users expect them to work.

Understand Events: Learn how event handling helps you separate your JavaScript from your HTML.

Play well with others: Make sure your script does not interfere with others, and make it hard for other scripts to interfere with yours.

Work for the next developer: Make maintenance easier by writing logical code with clear variable and function names and commenting where necessary.


It’s all excellent advice that goes beyond unobtrusive scripting and into the realm of general best practices.

I guess no matter which part of web development you look at there will always be people who couldn’t care less about craftsmanship and quality, and are always on the lookout for shortcuts and ways to shut out minorities.

For detailed information and coding, please follow the trackback link provided.

 
TrackBack URL:
0 comments on "Optimizing Javascript for the Web"
Add your comment on "Optimizing Javascript for the Web"

Rate:
Submit
JobSite for Investment Banking Professionals
  • Create a confidential Career Profile and Resume/C.V. online
  • Get advice for planning their career and for marketing of experience and skills
  • Maximize awareness of and access to the best career opportunities
Viewers also viewed
Unethical move to usurp our democratic rights vs Move to filter antinational content
 
78 referals 3 arguments, 138 views
The flexibility of changing in jobs is very different and difficult in India ( as far as my...
 
773 referals 43 arguments, 2335 views
i think it will be good to develop technology very fast vs it is not good to develop technology fast
 
1710 referals 27 arguments, 477 views
more...  
Recent Knowledge (77)
The subject should be rather in form of a statement. A bold statement . Yes!! Yes!! When you get...
 
1386 referals 8 comments, 104 views
The following is a reproduction of from an article I wrote in 2004. 1.  Harnessing the vast...
 
735 referals 18 comments, 325 views
HI The most stressful part of job interview is to get stuck in those questions which are generic...
 
0 referals 6 comments, 323 views
more...  
More From Author
I am in support of Rationalised Infrastructure. Our infrastructure is mobile, efficient, and disaster tolerant. Its modular nature allows highly granular control of IT resources with half the energy costs of standard "facilities" and associated...
BAN, 90% of people go these sites JUST wasting time.These sites must certainly be banned in colleges and university campuses.Students/lectures (young) waste such a hell lot of time doing meaningless stuff over here that its very irritable indeed....
Brand positioning creates a specific place in the market for your brand and product offerings. It reaches a certain type of consumer or customer and delivers benefits that meet the needs of several key target groups and users. It may be that Dove...
more...