Palo Alto 面试题:实现前端 Lazy Loading 并动态插入内容

23次阅读
没有评论

Problem Description (Original)

1. Problem

You are given a simple web page layout with a navigation menu:

Home   Products   About us

The page initially loads only the basic structure.


2. Solution / Requirement

Implement lazy loading, where content is loaded only when needed, instead of loading everything at page initialization.

You are also required to add content dynamically to the page using a JavaScript function.


Example: Function to Add Content Dynamically

<div>
  <h1>name</h1>
  <p>your name here</p>
</div>

The function should dynamically create and insert this content into the DOM at runtime.


这道题考察的是 前端基础能力而非算法
是否理解 Lazy Loading 的意义 ,以及是否能通过 JavaScript 动态创建并插入 DOM 节点,避免页面一次性加载所有内容。

正文完
 0