Here are some good practices to follow for Javascript. Remember that when you are using any programing language or scripting language when you define variables try to use a meaningful name, remember to put some internal documentation like I did to help explain to you what the code is doing, becuase 6 months later it save you a heck of allot of time when you are trying to remember or figure out how everything works. When you develop other projects or your own and you leave them to develop other things you loose track and having internal documentation will help.
Remember to close your variables with a semicolon. Declatartions like statements, end with a semicolon and ca be split over several lines with each vfariable in the declaration separated by a comma. To declare multiple Variables in javascript try this:
<script type = "text/javascript">
<!--
var super, slick, and, lots, of, diff, names;
// -->
<script />
</script>
August 30th, 2005
Splash, introduction pages, agreement pages, and just about anything else that stops you from getting to the content fast should be stripped from your website. Believe it or not, some people don’t care about how much money, or your skills in flash introductions, they actually come to your website not for the introduction but the actual content.
The initial use of the internet is to communicate. Communication can mean anything from sharing your files to chatting to your buddy on an IM application. Websites are like a document online, with hyperlinks and have transformed to be visually appealing. Even though we have added fancy text, text with shadows, and frogs which talk, the initial purpose of the webpage has not changed.
When you start your website there is many questions to ask your self like the title of the site, but the most important question is; ‘What is your website about?’, and ‘What is its purpose?’
I am going to do this with this website so you can see how planning works. This website is about Website Development and technologies. Its purpose is to educate and deliver content to the user about this. The key words – again this is debatable but for this paragraph – are deliver and content. Other sites may want to deliver another type of format of information, such as music, PDFs, applications and what ever else exists on the internet. Since our main priority is to deliver this content, delaying it is just contradicting the sites purpose.
The problems…
Remember that websites are not a movie; people do not need to be introduced through an animation which usually has nothing to do with what they are looking for. In fact if I was to put a Splash page on this site, and introduce other content on this site how long would it take to go through the whole splash? Even just the content from just last month would take a while to go through.
Many people create Splash pages with out putting a skip introduction link, which makes it impossible to get the content with out waiting. Or if they do put a link to skip the introduction, they incorporate it in their presentation which is usually a third-party plug-in, or Active-X control which many users (including me) disable it because it wastes to much – bandwidth (mine and theirs), time, processing power, security and space – so if some one doesn’t have flash enabled what are they going to see, a blank page with a Download Plug-in message in the middle.
I intentionally come late to movies at cinemas to miss opening titles and all the crap. Imagine a user coming back to your website again and again, and having to click skip all the time.
Haven’t I ever heard of the cookie?
You’re probably wondering “but you can prevent users from seeing the same message over and over by using a cookie?” The con’s is to this;
most some of the user’s browsers reject cookies a
- anti-spy ware software deletes cookies
- cookies expire –there’s ways out of this.
So no matter what you cannot cover the whole community of users, because not all users have cookies, have them enabled or keep them.
Imagine going to Google to search and you had to go through a presentation of what Google is, or its new features. There are better ways to illustrate content with out having a splash screen. Remember your initial purpose of your site.
Not convinced?
If you use Active-X, a third party application or a client side scripted script application, make sure that there is away around this to get to your content or your site. If your site is completely in Java, Flash or another plug-in Active X object
always provide an alternative, for accessibility purposes and search engine optimization.
Use cookies to redirect users after they have seen the presentation once, make sure the skip intro link always visible. If you are using flash, put the non-html page first and then use flash to redirect the user on the first frame. The purpose of this is so that you do not need to use a Client Side Script to check if the user has Flash, flash will redirect the user to your full flash object/page/movie/splash and if there is no flash then it cannot redirect, and you do need to put of search engines and other users because they be at the feet of the content.
I spent ages or allot of money to get this intro done… I don’t want to get rid of it
If you wish to show off your skills, I’m sure that 100% your audience or your future audience (which isn’t able to view your website due to its poor accessibility) doesn’t care or appreciate of your skills or wants to know or see how much money you spent creating this intro, or that it looks really good. If you must put a link on webpage to a splash page – this defeats the purpose of it to be the first thing but I don’t see a need for it at all.
I Agree/Disagree
If you need users to agree to content for what ever reason it is, you can get around this with disclaimers which are still visible to the user. If your site needs to have an I agree or Disagree chances are its not going to help you at all in court, and if you’re providing that sort of content you are probably using the internet for all the wrong reasons. Another alternative to this is making the page per membership so the user agrees once they log-in, the agreement is agreed through a contract which they accepted when they joined your site.
More Incorrect uses of the Splash Page
A splash page is not an about page, or an about us page, and it is nether a
FAQ pages or a privacy policy. These all have their right full places, and because you are using the splash page incorrectly – though I just stated there is no correct uses, the questions are still going to be asked, people will not know what your on about, and the people who do know what it’s about get frustrated because their wasting there time bandwidth etc. on junk that they have seen before.
Your opinions on this are appreciated comment below – even comment if you think their good I would like to know why.
Other
a I said this because when you are using Internet Explorer, which allot of users use because of x reasons, it blocks cookies with its ‘Privacy Report’ this site you may of noticed picks up cookies for one of the external stats programs
August 29th, 2005
Avoid Using JavaScript Writing Titles
You may of seen this example in one of the previous articles.
<title><script type="text/javascript">
document.write("Printing JavaScript Titles Using
JavaScript"); </script></title>
I do not recommend this because when you look in a search engine your results come up like this;
document.write(' '); var MYHAWEMEA_LANG=""; var ...
document.write(''); else document.write(''); function
showpage(strpage) {
window.open(myhaeurl ...
else if(MYHAWEMEA_SHOWFAQLINK == "PM"){ document.write(' ...
Use server side scripting like PHP do to the same thing
You Could Do the same thing with this code.
echo('<head>' '<title>Printing JavaScript Titles Using
JavaScript</title>');
</head>
The code is much smaller and the source code isn’t made available for the user because it’s generated by the server.
The same problems go for meta elements. You can find many sites which come up by search engines with this problem. Though now some search engines such as Google have advanced they still do not generate everything for their own reasons.
Alternative using JavaScript
You Could Try Doing Using This
document.write("<title>Printing JavaScript Titles Using JavaScript
</title>");
Why use this Because the search engine can still get information out of the document.
The Previous Way
The SearchBot May See All the Scripting
...<title><script type="text/javascript">document.write('This Is What The Search Engine Sees')</script></title>...
Alternative Method
The SearchBot Will Just Pull Out Whats Between The Title Tags
...<script type="text/javascript">document.write('<title>'This Is What The Search Engine Sees</title>')</script>...
At least using the alternative method your site is better exposed to more primative search bots.
August 29th, 2005