Front End Development Technology & Digital Applications 4 — Questions and Answers
Question 1: Which meta tag is essential for making a web page render correctly on mobile devices?
- <meta name="viewport" content="width=device-width, initial-scale=1"> (Correct answer)
- <meta name="mobile" content="true">
- <meta http-equiv="responsive" content="yes">
- <meta name="screen-width" content="auto">
Correct answer: <meta name="viewport" content="width=device-width, initial-scale=1">
The viewport meta tag instructs mobile browsers to set the viewport width to the device width and use a 1:1 zoom ratio, enabling responsive layouts.
Question 2: What does HTTPS provide that HTTP does not?
- Encrypted data transmission using TLS, preventing eavesdropping and tampering (Correct answer)
- Faster page load speeds through multiplexing
- Compression of HTML, CSS, and JavaScript responses
- Caching of static assets at the browser level
Correct answer: Encrypted data transmission using TLS, preventing eavesdropping and tampering
HTTPS wraps HTTP in TLS (Transport Layer Security) encryption, ensuring data is private and cannot be intercepted or modified in transit.
Question 3: In the context of web performance, what does 'Time to First Byte' (TTFB) measure?
- The time from a browser request until it receives the first byte of the server's response (Correct answer)
- The time until the first text content appears on screen
- The duration of the browser's DNS lookup
- The time until the page becomes fully interactive
Correct answer: The time from a browser request until it receives the first byte of the server's response
TTFB measures server responsiveness — the elapsed time from the browser sending a request to receiving the first byte of the HTTP response.
Question 4: What is the purpose of the 'Content-Security-Policy' (CSP) HTTP header?
- Restricting which sources can load scripts, styles, and other resources to prevent XSS attacks (Correct answer)
- Compressing the HTTP response body with gzip
- Enabling cross-origin requests from whitelisted domains
- Caching static resources for a specified duration
Correct answer: Restricting which sources can load scripts, styles, and other resources to prevent XSS attacks
CSP headers define approved content sources and block unauthorized scripts or resources, mitigating Cross-Site Scripting (XSS) and data injection attacks.
Question 5: What is 'code splitting' in modern JavaScript applications?
- Dividing the application bundle into smaller chunks loaded on demand (Correct answer)
- Separating HTML, CSS, and JavaScript into distinct files
- Distributing processing between the client and server
- Minifying each module independently before bundling
Correct answer: Dividing the application bundle into smaller chunks loaded on demand
Code splitting breaks the bundle into smaller pieces so only the code needed for the current route or feature is loaded, improving initial load time.
Question 6: Which browser API allows web applications to store structured data locally using an asynchronous, transactional database?
- IndexedDB (Correct answer)
- localStorage
- sessionStorage
- Web SQL
Correct answer: IndexedDB
IndexedDB is a low-level browser API for client-side storage of large amounts of structured data with indexed querying support.
Question 7: What does the 'defer' attribute on a <script> tag do?
- Downloads the script in parallel with HTML parsing and executes it after parsing is complete (Correct answer)
- Prevents the script from executing until the user interacts with the page
- Loads the script only when it enters the viewport
- Executes the script immediately, blocking HTML parsing
Correct answer: Downloads the script in parallel with HTML parsing and executes it after parsing is complete
The `defer` attribute tells the browser to download the script without blocking parsing and to execute it after the HTML document has been fully parsed.
Which meta tag is essential for making a web page render correctly on mobile devices?