Unit 5: Performance, SEO, and Deployment - Subjective Questions
INT257 — Modern Web Application Development • Practice Questions with Detailed Answers
20 questions
Explain the importance of image optimization in modern web applications. Describe at least four techniques used to optimize images.
Image optimization reduces the amount of data that browsers must download, improving loading speed, user experience, and search engine performance.
Important techniques include:
- Choose suitable formats: Use WebP or AVIF for efficient compression, JPEG for photographs, and PNG or SVG for images requiring transparency or lossless quality.
- Resize images: Serve images close to their displayed dimensions instead of downloading unnecessarily large files.
- Compress images: Reduce file size using lossy or lossless compression while maintaining acceptable visual quality.
- Use responsive images: Use
srcsetand thesizesattribute to deliver different image resolutions for different devices. - Lazy-load images: Load below-the-fold images only when they are close to entering the viewport.
- Provide dimensions: Set image width and height to reduce layout shifts during loading.
These practices reduce bandwidth usage and can improve metrics such as Largest Contentful Paint (LCP) and Cumulative Layout Shift (CLS).
Compare WebP, AVIF, JPEG, PNG, and SVG image formats with respect to their use cases, advantages, and limitations.
The choice of image format affects file size, quality, browser compatibility, and rendering performance.
- JPEG: Suitable for photographs and complex images. It provides good lossy compression but does not support transparency and may show artifacts at high compression levels.
- PNG: Suitable for logos, screenshots, and images requiring transparency or lossless quality. However, PNG files are often larger than equivalent WebP or AVIF files.
- WebP: Supports lossy and lossless compression, transparency, and animation. It generally provides smaller files than JPEG and PNG, with broad modern browser support.
- AVIF: Provides excellent compression and high image quality, often producing smaller files than WebP. Encoding can be slower, and support in older browsers may be limited.
- SVG: A vector format ideal for icons, logos, and diagrams. It scales without loss of quality, but it is not appropriate for photographs and must be sanitized when accepting untrusted files.
A production application may use AVIF or WebP with fallback formats when compatibility is important.
Describe how a Metadata API can be used to manage page titles, descriptions, canonical URLs, Open Graph data, and robots directives in a web application.
A Metadata API provides a structured way to define document metadata for each route or page.
It can manage:
- Page titles: Set a unique and meaningful
<title>for every page. - Meta descriptions: Provide concise summaries that search engines may display in result pages.
- Canonical URLs: Identify the preferred URL when similar content is accessible through multiple URLs.
- Open Graph metadata: Define the title, description, URL, and preview image used when content is shared on social platforms.
- Robots directives: Control whether search engines index a page or follow its links.
- Structured metadata: Add information such as article, product, or organization details when supported by the framework.
The metadata should be generated from route-specific data rather than duplicated across all pages. Titles and descriptions should accurately describe the visible content, and canonical URLs should use the correct production origin. Metadata APIs also reduce errors caused by manually editing HTML templates.
Explain code splitting and distinguish between route-based code splitting, component-based code splitting, and vendor splitting.
Code splitting divides a large JavaScript bundle into smaller chunks that can be downloaded when needed. This reduces the initial JavaScript payload and can improve the time required to become interactive.
- Route-based code splitting: Each route or page is placed in a separate chunk. The chunk is loaded when the user navigates to that route.
- Component-based code splitting: Large or rarely used components, such as charts, editors, and dialogs, are loaded dynamically only when required.
- Vendor splitting: Third-party dependencies are placed into separate chunks so that they can be cached independently from frequently changing application code.
Code splitting should be applied thoughtfully. Excessive splitting may create many network requests and increase overhead. A good strategy loads critical code immediately and defers features that are unlikely to be used during the first interaction.
Explain lazy loading in web applications. Describe how lazy loading can be applied to images, routes, components, and data requests.
Lazy loading postpones the loading of a resource until it is likely to be needed.
Examples include:
- Images: Use native lazy loading or an intersection observer for images below the fold.
- Routes: Load route-specific JavaScript only when the user visits the route.
- Components: Dynamically import expensive components such as maps, charts, or rich text editors.
- Data: Fetch secondary or paginated data after the primary content is displayed.
- Videos and embeds: Defer third-party players and media until the user interacts with them.
Lazy loading improves initial load performance and reduces bandwidth consumption. However, critical above-the-fold content should not be lazy-loaded because doing so can delay rendering. Applications should also provide loading states, error handling, and accessible fallback content.
Discuss the fundamental principles of SEO for a modern web application. Include technical, content, and usability considerations.
Search Engine Optimization (SEO) improves the ability of search engines to discover, understand, and rank application content.
Key principles include:
- Crawlability: Use accessible links, valid status codes, a suitable
robots.txtfile, and an XML sitemap where appropriate. - Indexability: Ensure important pages are not accidentally blocked by robots directives or authentication requirements.
- Meaningful content: Provide original, useful content that satisfies the user's search intent.
- Semantic HTML: Use headings, landmarks, lists, labels, and descriptive link text correctly.
- Metadata: Provide unique titles, descriptions, canonical URLs, and social sharing metadata.
- Performance: Optimize Core Web Vitals, JavaScript, images, and server response time.
- Mobile usability: Ensure responsive layouts, readable text, suitable tap targets, and stable content.
- Accessibility: Support keyboard navigation, alternative text, focus management, and clear language.
SEO is not only keyword placement; it combines technical quality, content relevance, accessibility, and user experience.
Explain the role of semantic HTML, headings, alternative text, and structured data in improving SEO and accessibility.
Semantic HTML gives content a meaningful structure that can be understood by browsers, assistive technologies, and search engine crawlers.
- Semantic elements: Elements such as
<main>,<nav>,<article>, and<footer>communicate the purpose of page regions. - Heading hierarchy: A logical sequence from the main heading to lower-level headings helps users and crawlers understand content organization.
- Alternative text: Descriptive
alttext explains the purpose of meaningful images. Decorative images should generally use empty alternative text. - Descriptive links: Link text should describe its destination instead of using vague phrases such as "click here."
- Structured data: Schema-based structured data can describe entities such as products, articles, events, and organizations. It may enable enhanced search results when the markup is valid and the content is visible and accurate.
These practices improve comprehension and navigation while making page meaning clearer to search engines.
Describe the stages involved in creating a production build for a web application. Explain why each stage is important.
A production build converts development source code into optimized deployable assets.
Typical stages are:
- Dependency installation: Install locked, production-compatible dependency versions to ensure reproducibility.
- Compilation and bundling: Transform source code and combine modules into browser-compatible assets.
- Minification: Remove unnecessary whitespace, comments, and code characters to reduce file size.
- Tree shaking: Remove unused exports and unreachable code from the final bundles.
- Asset processing: Optimize images, fonts, stylesheets, and static files.
- Environment injection: Include only the configuration values intended for the selected environment.
- Hashing: Add content hashes to filenames so browsers can cache assets safely while receiving updated files after changes.
- Testing and validation: Run unit tests, integration tests, linting, type checks, and build verification.
- Artifact generation: Produce the final files or container image that will be deployed.
A production build improves performance, consistency, security, and deployment reliability.
Derive a practical performance optimization strategy for a web application whose initial JavaScript bundle and image assets are too large. Justify the order of your actions.
A practical strategy should prioritize changes that reduce the largest contributors to the initial load.
- Measure first: Use bundle analyzers, browser developer tools, and performance audits to identify large JavaScript modules, images, fonts, and third-party scripts.
- Optimize the largest images: Resize them, compress them, convert them to WebP or AVIF, and provide responsive variants. This often produces an immediate reduction in transferred bytes.
- Remove unused dependencies: Replace heavy libraries with smaller alternatives where appropriate and enable tree shaking.
- Apply route-based code splitting: Keep the JavaScript required for the first route small and load other routes on demand.
- Lazy-load secondary components: Defer charts, maps, editors, and below-the-fold content.
- Reduce third-party code: Remove unnecessary analytics, widgets, and tracking scripts or load them after the main content.
- Optimize fonts and CSS: Use fewer font variants, preload only critical fonts, and remove unused styles.
- Verify the result: Compare bundle sizes, Core Web Vitals, real-user metrics, and error rates before and after the changes.
This order addresses measurable bottlenecks first and prevents optimization work from being based on assumptions.
Explain environment configuration in web applications. Distinguish between public configuration and secrets, and describe safe configuration practices.
Environment configuration allows the same application code to run with different settings in development, testing, staging, and production.
Examples include API base URLs, feature flags, logging levels, database connection information, and service endpoints.
- Public configuration: Values such as a public API URL or analytics identifier may be exposed to the browser if they are designed to be public.
- Secrets: Passwords, private API keys, signing keys, and database credentials must remain on the server and must never be bundled into client-side JavaScript.
Safe practices include:
- Store secrets in a secret manager or protected deployment environment.
- Keep an example configuration file containing names but not real values.
- Validate required variables during startup or build time.
- Use different credentials for each environment.
- Avoid committing
.envfiles containing secrets. - Restrict permissions and rotate credentials regularly.
- Ensure client-exposed variables use an explicit public naming convention supported by the framework.
Configuration should be documented and reproducible without exposing sensitive data.
Compare static hosting, serverless deployment, container-based deployment, and traditional virtual-machine deployment platforms.
Deployment platforms differ in control, scalability, operational effort, and supported application architecture.
- Static hosting: Serves prebuilt HTML, CSS, JavaScript, and media files through a CDN. It is inexpensive and fast but cannot directly run long-lived server processes.
- Serverless deployment: Runs functions or managed application services on demand. It scales automatically and reduces server management, but execution limits, cold starts, and platform-specific behavior may matter.
- Container-based deployment: Packages the application and its dependencies into a container image. It provides portability and consistent runtime behavior, but teams must manage images, health checks, networking, and resource limits.
- Virtual-machine deployment: Provides significant operating-system and runtime control. It supports many workloads but requires more maintenance, patching, scaling configuration, and monitoring.
The appropriate choice depends on whether the application is static, server-rendered, API-driven, stateful, latency-sensitive, or subject to compliance requirements.
Describe a reliable deployment pipeline for a web application from source control to production. Include testing, review, rollback, and post-deployment checks.
A reliable deployment pipeline automates repeatable checks and makes releases observable and reversible.
- Source control trigger: Start the pipeline when a pull request is opened or changes are merged.
- Static validation: Run formatting checks, linting, type checks, and dependency audits.
- Automated tests: Execute unit, integration, end-to-end, and build tests appropriate to the application.
- Review and approval: Require peer review and verify that configuration and migration changes are understood.
- Artifact creation: Build a versioned production artifact once and promote that artifact between environments.
- Staging validation: Test the artifact with production-like settings and data-safe integration services.
- Production release: Deploy using rolling, blue-green, or canary techniques when the risk justifies them.
- Post-deployment checks: Verify health endpoints, logs, error rates, response times, critical user journeys, and database status.
- Rollback: Keep the previous known-good artifact available and define a clear rollback procedure.
The pipeline should also record who deployed a release, what changed, and which artifact is running.
Explain performance monitoring and distinguish between synthetic monitoring, real-user monitoring, and application performance monitoring.
Performance monitoring measures whether an application is fast, reliable, and responsive for its users.
- Synthetic monitoring: Automated tests run from controlled locations and devices. They are useful for repeatable comparisons, uptime checks, and detecting regressions before users report them.
- Real-user monitoring (RUM): Collects performance data from actual users, devices, browsers, networks, and geographic regions. It reveals variations that synthetic tests may not capture.
- Application Performance Monitoring (APM): Observes server-side requests, database queries, external services, throughput, latency, and resource utilization.
Important measurements include:
- Largest Contentful Paint (LCP)
- Interaction to Next Paint (INP)
- Cumulative Layout Shift (CLS)
- Time to First Byte (TTFB)
- Request latency and error rate
- JavaScript execution time
- Cache hit ratio and resource transfer size
Monitoring should use baselines, thresholds, dashboards, and alerts so that teams can identify and prioritize regressions.
Explain the purpose of error logging in production applications. What information should a useful error log contain, and what information should it exclude?
Error logging records failures so developers can diagnose problems, measure their impact, and restore service.
A useful log or error event may contain:
- Timestamp in a consistent timezone or standard format
- Severity level
- Error type and message
- Stack trace on the server
- Request or trace identifier
- Route, operation, and service name
- Application version or deployment identifier
- Sanitized user, device, and environment context
- Relevant status code and dependency information
Logs should exclude passwords, authentication tokens, private keys, full payment details, and unnecessary personal data. Sensitive values should be redacted before transmission.
Production logging should use structured formats such as JSON, centralize collection, support searching and correlation, and apply retention policies. Error aggregation can group repeated failures and notify teams when an error rate or severity threshold is exceeded.
Compare browser-side error monitoring with server-side error monitoring. Explain how correlation identifiers improve debugging across both layers.
Browser-side and server-side monitoring observe different parts of the request lifecycle.
- Browser-side monitoring: Captures JavaScript exceptions, failed resource loads, rendering problems, route failures, user interactions, and client performance data.
- Server-side monitoring: Captures API exceptions, authentication failures, database errors, dependency failures, queue problems, and resource exhaustion.
A correlation identifier, such as a request ID or trace ID, is generated for a request and propagated through the browser, gateway, backend services, and logs. When an error occurs, engineers can use that identifier to connect:
- The user's browser event
- The corresponding network request
- Server logs and stack traces
- Database or external service calls
- The deployed application version
This reduces investigation time because the complete path of one failing operation can be reconstructed. Identifiers should not contain sensitive information and should be handled consistently across services.
Describe how caching, content delivery networks, compression, and HTTP response headers improve production web application performance.
Production performance improves when browsers and edge servers avoid repeatedly downloading unchanged resources.
- Browser caching: Cache-Control headers allow browsers to reuse assets without making new requests.
- Content delivery networks: A CDN serves static assets from locations closer to users, reducing network latency.
- Content hashing: Hashed filenames allow long-lived caching because a changed file receives a new URL.
- Compression: Brotli or gzip reduces the size of text-based HTML, CSS, JavaScript, JSON, and SVG responses.
- Conditional requests:
ETagorLast-Modifiedallows a server to return a small304 Not Modifiedresponse when content has not changed. - Preload and preconnect: These resource hints can prioritize truly critical resources and reduce connection setup time.
- Security and policy headers: Headers such as Content Security Policy, HSTS, and suitable cache policies improve operational safety, although they must be configured without blocking required resources.
Caching policies should distinguish immutable versioned assets from dynamic HTML and user-specific responses.
Explain the relationship between Core Web Vitals and user experience. Describe practical methods for improving LCP, INP, and CLS.
Core Web Vitals measure important aspects of the user experience.
- Largest Contentful Paint (LCP): Measures how quickly the main visible content appears. Improve it by reducing server response time, optimizing the LCP image, preloading only critical resources, reducing render-blocking CSS, and using a CDN.
- Interaction to Next Paint (INP): Measures responsiveness after user interactions. Improve it by reducing long JavaScript tasks, splitting large bundles, limiting third-party scripts, and moving expensive work away from the main thread.
- Cumulative Layout Shift (CLS): Measures unexpected movement of visible content. Improve it by reserving image and video dimensions, allocating space for advertisements and embeds, avoiding late-inserted content, and using stable font loading strategies.
These metrics should be evaluated with both laboratory tools and real-user monitoring because actual network conditions and devices vary.
Design an SEO and performance checklist for deploying a server-rendered or statically generated web application.
A deployment checklist should verify both discoverability and delivery performance.
SEO checks:
- Every important route has a unique title and meta description.
- Canonical URLs use the correct production domain.
- Open Graph and social preview metadata are valid.
- Important content is rendered in the initial HTML.
- Headings and semantic landmarks are logically structured.
- Images have useful alternative text and descriptive filenames where appropriate.
robots.txtdoes not block important content.- The sitemap contains canonical, indexable URLs.
- Redirects, status codes, and custom error pages work correctly.
Performance checks:
- Images are compressed, responsive, and dimensioned.
- Critical JavaScript and CSS are minimized.
- Routes and heavy components are code-split.
- Below-the-fold resources are lazy-loaded.
- Static assets are compressed and served through a CDN.
- Cache headers are appropriate for immutable and dynamic resources.
- Core Web Vitals are measured in a representative environment.
The final step is to inspect the deployed site with crawlers, browser tools, and real-user monitoring.
Explain how to identify and reduce JavaScript bundle bloat in a production web application.
JavaScript bundle bloat occurs when the browser must download, parse, compile, and execute more code than necessary.
A reduction process includes:
- Analyze bundle composition: Use a bundle analyzer to locate large libraries, duplicated modules, and unexpectedly included files.
- Remove unused packages: Delete dependencies that are no longer needed.
- Prefer modular imports: Import only required functions instead of loading an entire library.
- Enable tree shaking: Use an appropriate production build configuration and ES module syntax.
- Split by route and feature: Load code only when a user accesses the relevant route or component.
- Replace heavy libraries: Use platform APIs or smaller alternatives when they provide equivalent functionality.
- Defer nonessential scripts: Load analytics and secondary widgets after critical interaction is available.
- Avoid duplicated dependencies: Align package versions and inspect dependency graphs.
- Measure execution cost: A small compressed bundle can still be expensive if it performs excessive startup work.
The result should be evaluated using transfer size, parse and execution time, and real-user responsiveness.
Distinguish between build-time and runtime environment configuration. Give examples of problems caused by using the wrong type.
Build-time configuration is read while the application is being compiled or bundled. Values may be embedded into the generated client assets. Examples include feature flags used for dead-code elimination and a public API base URL.
Runtime configuration is read when the application starts or handles a request. It is useful for server-only secrets, deployment-specific service endpoints, and values that must change without rebuilding the frontend.
Problems caused by incorrect usage include:
- A secret placed in a build-time client variable becomes visible to every browser user.
- A frontend built with a staging API URL may continue calling staging after production deployment.
- Changing a runtime value may have no effect if it was already embedded into static JavaScript.
- A missing variable may produce invalid URLs or cause startup failures.
- Environment-specific feature flags can become inconsistent across server and client code.
Configuration should be classified explicitly, validated, and tested in the same form used by the deployment platform.
Explain the importance of image optimization in modern web applications. Describe at least four techniques used to optimize images.
Image optimization reduces the amount of data that browsers must download, improving loading speed, user experience, and search engine performance.
Important techniques include:
- Choose suitable formats: Use WebP or AVIF for efficient compression, JPEG for photographs, and PNG or SVG for images requiring transparency or lossless quality.
- Resize images: Serve images close to their displayed dimensions instead of downloading unnecessarily large files.
- Compress images: Reduce file size using lossy or lossless compression while maintaining acceptable visual quality.
- Use responsive images: Use
srcsetand thesizesattribute to deliver different image resolutions for different devices. - Lazy-load images: Load below-the-fold images only when they are close to entering the viewport.
- Provide dimensions: Set image width and height to reduce layout shifts during loading.
These practices reduce bandwidth usage and can improve metrics such as Largest Contentful Paint (LCP) and Cumulative Layout Shift (CLS).
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →