CS202 GDB1 Solution and discussion
Suppose you are working as a web designer and you have developed a website for some client. Your supervisor is concerned with layout of your website. He has conducted a meeting with you to correct issues related to layout of website, so you have to quickly respond to his requirements and change the website layout quickly. After making quick changes, you have to consider the factor of maintainability too. You have been given two options, CSS Inline styling and external styling to style your web pages. So, by considering quick response and maintainability factors, which option you will use for above scenario? Justify your answer with solid points.
AJAX is a technique for creating fast and dynamic web pages. AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.
Suppose you are assigned a task to develop a web application for stock exchange market. One of the client requirements is to show the updated stock exchange data of Pakistan, China, America, Australia and India. The data of Pakistan, China America, Australia and India should be updated after every 2 seconds, 4 seconds, 1 second, 6 seconds and 8 seconds respectively. Another requirement is to show summary of updated data of all given countries after every 8 seconds. If you as a developer are provided with the following two options to choose to implement the above requirements, which option would you prefer and why? Support your answer with solid arguments.
Option1: Use AJAX
Option 2: Reload whole page after each update
Give your opinion with solid reasons to support your answer.
Imagine if your css is in inline styles through a 1000 pages of your site. How an earth can you respond quickly as you would need to change all 1000 pages. With an external stylesheet the changes can be made in seconds and the css is cached for the whole site unlike inline styling.
Inline styling is mainly used these days for above the fold rendering on speed critical sites but used very sparingly. Most websites do not need this type of structure if coded correctly in the first place.
Avoid inline styling at all costs unless you have a justified use case as mentioned above or perhaps for dynamic styling with js for some special effects.
In general stylesheets should be external.
External styling all the way. Inline styling may be “quicker” in the short run, but over time, it’s going to be a nightmare to maintain, and the chances of inconsistency grows exponentially…