LeetQuiz Logo
Privacy Policy•contact@leetquiz.com
© 2025 LeetQuiz All rights reserved.
Google Professional Cloud Developer

Google Professional Cloud Developer

Get started today

Ultimate access to all questions.


How should you design a single-page web application where the UI communicates with a third-party API via XMLHttpRequest, ensuring that non-critical API data doesn't block UI rendering, while maintaining good performance during API errors or timeouts?

Exam-Like



Explanation:

The key requirements are that API calls should not delay UI rendering and it's acceptable to omit the API data on errors.

  • Option A uses synchronous requests (asynchronous: false), which block the UI thread, delaying rendering. This violates the requirement to avoid delaying other parts of the UI.
  • Option B uses asynchronous requests (asynchronous: true), allowing non-blocking UI rendering. Omitting the widget on errors aligns with the requirement to tolerate missing API data.
  • Option C implements retries with exponential backoff, which is unnecessary since the API data is non-critical and errors are acceptable.
  • Option D displays errors in the UI, which contradicts the instruction to omit the widget entirely on failures.

Thus, B is the correct choice as it satisfies both non-blocking UI and graceful handling of API failures.

Powered ByGPT-5