4 . Explain in your own words the following: a. Should we place JavaScript in the HTML head or body? Please specify the necessary arguments for your choice. JavaScript is usually placed in head since head contains the information which is hidden from the user, for example meta-data, key words etc. If page is referring to any external files like css file, external JavaScript file or Jquery library all the linked to the page in the head section. But the problem in writing the script in the head is when even page loads the browser first load all the information from head section including script. The body section gets loaded once all the script is downloaded, parsed and executed. This will block the page to gets loaded. b. Which JQuery event allows for proper handling of JavaScript code present in the HTML document head section? $(Document.ready) action - Because this even is called when entire page is loaded and document is ready for any action. c. Provide example web application use cases that require: Asynchronous communication Synchronous communication Asynchronous Communication: when client makes a request to the server, server takes some time to process the request, during this period the client is not blocked to perform further activities. This kind of communication is very useful and increase the user engagement. There is very strong belief that if request is not carrying important information then user should not wait for the acknowledgment from the server. Example: Online polling. User polls and enters his opinion, then till the server updates, he should not be blocked for further communication. Synchronous Communication: when client makes a request to the server, server takes some time to process the request, during this period the client has to wait for the response from the server and blocked to do any other activities. Example: One very good example is "Payment Portal", whenever user does the online transaction, once user confirm the payment, user will be asked to wait till he received the acknowledgement from the server.
© Copyright 2026 Paperzz