Web Hosting Talk







View Full Version : Javascript usage


BlueHayes
12-06-2008, 03:31 PM
Javascript usage

Ok so I'm starting to use Javascript more when developing websites, it can do wonders! From "special" effects (clean ones not a website scattered in rubbish) to great functionality and improved interface for the end user.
How can I make sure my Javascript isn't going to cause problems with certain peoples computers/browsers, is it possible for Javascript to cause many problems (as long as there aren't endless loops and so on being ran)?
For example I was using a nice fading effect I wrote using timeouts (or an interval) but noticed with lots of usage this could cause firefox to begin seeming "laggy" for me.
Scripts running "onload", for example looping through every image element or anchor element on the page - how bad can this become if not very carefuly looked after?
Sorry I'm not entirely sure on the workings of Javascript, though I have read when searching about optimization that JS processes one thing at a time basically, in an order/queue.
Thanks for any help, again (as with other threads I've started) this could seem quite vague because there is probably so much information for me to learn on the way to true optimization.





__________________I recommend PoundHost for UK dedicated and virtual servers, without a doubt.
For cheap OpenVZ virtual servers try CheapVPS.co.uk or FsckVPS.com

stdunbar
12-08-2008, 07:36 PM
When done correctly Javascript can greatly add to the end user experience. However, as you've begun to see, there are gaps in support from the different browsers.
Short of having a rather large lab of computer/browser combinations I'd really encourage you to look at a library that has been designed for this. There are many toolkits out there to help you. Everyone has their personal favorite but I've used Dojo for some projects and MooTools for others. There are many more out there but the key is that through Javascript, CSS, and HTML these toolkits hide much of the complexity of cross-browser Javascript.





__________________Need Java help? Want to help people who do? Sit down with a cup of Java at the hotjoe forums.