0
0
Angularframework~20 mins

SSR vs CSR mental model in Angular - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SSR vs CSR Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding Server-Side Rendering (SSR) vs Client-Side Rendering (CSR)
Which statement best describes the main difference between SSR and CSR in Angular applications?
ASSR renders the initial HTML on the server before sending it to the browser, while CSR renders the HTML entirely in the browser after loading JavaScript.
BCSR renders the initial HTML on the server, and SSR renders HTML only after user interaction in the browser.
CSSR requires no JavaScript on the client, while CSR requires JavaScript only on the server.
DCSR sends fully rendered HTML from the server, and SSR sends only JSON data to the client.
Attempts:
2 left
💡 Hint
Think about where the first HTML content is created: server or browser.
component_behavior
intermediate
1:30remaining
Behavior of Angular Components in SSR vs CSR
In an Angular app using SSR, what happens to component lifecycle hooks like ngOnInit during server rendering?
AngOnInit does not run during SSR; it only runs in the browser after hydration.
BngOnInit runs twice: once on the server and once again on the client after hydration.
CngOnInit runs on the server during SSR, so data can be fetched before sending HTML to the client.
DngOnInit is replaced by a special SSR lifecycle hook that runs only on the server.
Attempts:
2 left
💡 Hint
Consider when Angular runs component code during server rendering.
state_output
advanced
2:00remaining
State Transfer Between SSR and CSR in Angular
Consider an Angular app using SSR with state transfer. After server rendering, what happens to the application state when the client bootstraps?
AThe client re-fetches all data ignoring the server state, causing duplicate requests.
BThe client merges server state with local storage data, which can cause conflicts.
CThe client clears all server state and starts fresh with empty data.
DThe client uses the transferred state from the server to avoid re-fetching data, speeding up hydration.
Attempts:
2 left
💡 Hint
Think about how SSR can improve client startup performance.
📝 Syntax
advanced
2:00remaining
Identifying SSR-Compatible Angular Code
Which Angular code snippet is NOT compatible with SSR and will cause errors during server rendering?
Angular
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-example',
  template: `<p>{{message}}</p>`
})
export class ExampleComponent implements OnInit {
  message = '';

  ngOnInit() {
    this.message = window.navigator.userAgent;
  }
}
AThe code uses window.navigator in ngOnInit, which is undefined on the server and causes errors.
BThe code uses a template string with interpolation, which is fully supported in SSR.
CThe component uses OnInit lifecycle hook, which runs on the server during SSR.
DThe component defines a class property and updates it in ngOnInit, which is valid in SSR.
Attempts:
2 left
💡 Hint
Remember that some browser APIs do not exist on the server.
🔧 Debug
expert
2:30remaining
Debugging Hydration Mismatch in Angular SSR
An Angular SSR app shows a hydration mismatch warning in the browser console after loading. Which cause is most likely responsible?
AThe server failed to send any HTML, so the client renders everything from scratch.
BThe server rendered HTML and client app have different initial states causing DOM differences during hydration.
CThe client app is missing JavaScript files, so hydration cannot run.
DThe server rendered HTML uses deprecated Angular syntax not supported by the client.
Attempts:
2 left
💡 Hint
Hydration mismatch means the browser sees different HTML than expected from the client app.