Javascript is often useful for website design. It can allow you to dynamically generate content for individual visitors. You can load content dynamically using AJAX. You can create animations that may increase the effectiveness of your website.
However, Javascript has some drawbacks too.
1. Increased Loading Time
In order for your Javascript to be loaded by your visitors' browsers it will need to be downloaded to their computer. This increases the amount of time required to load your webpage.
If you have a very fast internet connection, this may seem insignificant. Javascript files are often smaller than 100kB, and on a modern wireless or Ethernet connection it will load in less than a second.
However, not all visitors to your website will have a fast internet connection. Some may living in remote locations with slow internet connections. Remember dialup? Some internet connections haven't gotten much faster than that.
Your webpage may also downloaded by people on mobile devices. While cellphone data connections are getting faster, in many areas, especially in rural parts of the world away from cities, internet connections are still slow. If you use Javascript on your website, your visitors on these connections will have to wait for it to download.
2. Increased Waiting Time
After your Javascript has loaded, your visitors' computers will need to execute your code. If you are using a fast, modern computer, your browser can probably perform your Javascript quickly and easily.
However, not everybody uses a developer-level computer. Some people use computers that will require a significant amount of time to even start up a browser.
If your Javascript requires a large amount of time to complete, visitors with slower computers will need to wait... and wait... for your Javascript to be performed. This may even prevent them from using their computer in other ways.
Having to wait can greatly decrease the quality of these visitors' experience.
3. Different Implementations
Just like CSS is implemented differently on different computers by different browsers, Javascript is executed differently depending on the visitors' machine. This can cause your Javascript to not work or even make your website unusable.
In general, there are commonly agreed upon standards for how portions of code should be executed. However, not every browser agrees to follow all of the rules. Internet Explorer has historically failed to accept web development standards, causing problems for web developers. (But, thankfully for developers, Microsoft has been getting better about complying with them.)
In addition to browser differences, your code will likely need to operate differently depending on each visitors' individual machine. Windows, Mac OS, Linux, iOS, Android, and other operating systems all have slightly different (or some times very different) ways of displaying website content.
To compensate for these differences, you will need to design your Javascript to work with all of these different OSs.
In addition, your javasript will need to work with different screen sizes. If you have Javascript that influences an image that it assumes is 500px by 500px, and a visitor's screen decreases the size of the image, your Javascript may not work as you intended. It may harm the appearance of the image or even make the entire page unusable.
Because of the complexity of implementing Javascript for different browser, OS, and machine configurations, it is usually easier to use alternatives, such as CSS, where possible.
Source by David J Selden-Treiman
Post a Comment