0Pricing
Web Performance Optimization & Lighthouse · บทเรียน

การตรวจติดตามและแจ้งเตือนงบประมาณ

สร้างระบบตรวจติดตามและแจ้งเตือนอัตโนมัติ เพื่อให้อยู่ภายในงบประมาณประสิทธิภาพที่กำหนดไว้

การตรวจติดตามและแจ้งเตือนงบประมาณ เป็นบทเรียน Web Performance Optimization & Lighthouse ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Web Performance Optimization & Lighthouse และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Web Performance Optimization & Lighthouse มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Why Monitor Performance Budgets?

You've learned to set performance budgets. But how do you ensure your website stays within those limits as it evolves? That's where continuous monitoring and alerting come in!

Monitoring helps you:

  • Catch regressions early: Identify performance drops before they impact users.
  • Maintain quality: Ensure new features don't unintentionally slow things down.
  • Stay competitive: Keep your site fast and responsive, meeting user expectations.

What Can We Monitor?

Performance budgets aren't just about page load time. They can apply to various aspects of your website:

  • Resource Size: Total JavaScript, CSS, or image bundle size.
  • Performance Scores: Lighthouse scores for performance, accessibility, etc.
  • Metric Thresholds: Specific Core Web Vitals like Largest Contentful Paint (LCP) or Cumulative Layout Shift (CLS).
  • Request Count: The number of network requests your page makes.

Continuous monitoring helps track these against your predefined limits.

Build-Time Budget Checks

One of the earliest points to check performance budgets is during your project's build process. Tools like Webpack, a popular JavaScript module bundler, can be configured to warn or error if certain asset size budgets are exceeded.

This prevents large files from even making it to deployment, catching issues before they reach users.

Webpack Performance Hints

Webpack allows you to define performance hints in your configuration. These hints will issue warnings or throw errors if your bundles exceed specified sizes.

Here's a simple example in a webpack.config.js file:

module.exports = {
  // ... other webpack config
  performance: {
    hints: 'warning', // Can be 'error' or false
    maxAssetSize: 200 * 1024, // 200 KiB
    maxEntrypointSize: 250 * 1024, // 250 KiB
    assetFilter: function(assetFilename) {
      return !/(\.map$|^favicon\.ico$)/.test(assetFilename);
    }
  }
};

Continuous Integration (CI) for Budgets

For more comprehensive checks, especially against metrics like Lighthouse scores or Core Web Vitals, you can integrate performance budget monitoring into your Continuous Integration (CI) pipeline.

A CI pipeline automatically runs tests and builds your code whenever changes are pushed. By adding performance checks, you can:

  • Automate audits: Run Lighthouse or other tools on every code change.
  • Fail builds: Prevent deployments if performance budgets are violated.
  • Get instant feedback: Developers see performance issues directly in their pull requests.

Lighthouse CI Budget Assertions

Lighthouse CI is an excellent tool for integrating performance checks into your CI pipeline. It allows you to define specific assertions (rules) that your Lighthouse audit results must meet.

If any assertion fails, Lighthouse CI can mark your build as a failure. This ensures your performance never drops below a baseline.

Here's how you might define budgets in a .lighthouserc.json file:

{
  "ci": {
    "collect": {
      "url": "http://localhost:8080"
    },
    "assert": {
      "assertions": {
        "performance-score": ["error", {"minScore": 0.90}],
        "interactive": ["error", {"maxNumericValue": 3000}],
        "total-blocking-time": ["warn", {"maxNumericValue": 200}]
      },
      "budgets": [{
        "resourceSizes": [
          {"resourceType": "script", "budget": 170},
          {"resourceType": "image", "budget": 250}
        ],
        "resourceCounts": [
          {"resourceType": "script", "budget": 10}
        ]
      }]
    }
  }
}

Types of Alerts

When a performance budget is exceeded, you need to know about it! Alerts can take various forms:

  • Build Failure: The most direct alert, stopping deployment until fixed.
  • Notifications: Messages sent to team communication channels (Slack, Microsoft Teams).
  • Email Reports: Detailed summaries sent to specific individuals or mailing lists.
  • Dashboard Warnings: Visual indicators on monitoring dashboards.

The goal is to make performance issues visible and actionable for your team.

Setting Up Notification Channels

Many CI/CD platforms and monitoring tools offer integrations with popular communication services. For example, if your Lighthouse CI audit fails, you can configure your pipeline to:

  • Post a message to a Slack channel.
  • Send an email to the development team.
  • Create an issue in a project management tool like Jira.

These integrations ensure that the right people are informed immediately when budgets are breached.

Real User Monitoring (RUM) Alerts

While build-time and CI checks are proactive, Real User Monitoring (RUM) provides insights into actual user experiences. RUM tools collect performance data directly from your users' browsers.

You can set up RUM alerts for:

  • Core Web Vitals: Alert if a certain percentage of users experience LCP or CLS above your thresholds.
  • Error Rates: Notify if JavaScript errors spike, potentially impacting performance.
  • Geographic Performance: Get alerts if users in a specific region experience slow loading times.

RUM alerts help you react to real-world performance degradations.

Quick Check: Budget Monitoring

Which of the following are effective ways to monitor and receive alerts about performance budget violations?

Recap: Staying Within Budget

Great job! You've learned how critical continuous monitoring and alerting are for maintaining web performance.

  • We explored how build tools like Webpack can enforce size budgets.
  • We saw how CI/CD pipelines, especially with tools like Lighthouse CI, automate checks and fail builds on budget breaches.
  • We discussed various alerting mechanisms, from build failures to notifications.
  • And finally, we touched upon Real User Monitoring (RUM) for real-world performance alerts.

By implementing these strategies, you can ensure your website consistently meets its performance goals.

คำถามที่พบบ่อย

บทเรียน “การตรวจติดตามและแจ้งเตือนงบประมาณ” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “การตรวจติดตามและแจ้งเตือนงบประมาณ” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Web Performance Optimization & Lighthouse ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Web Performance Optimization & Lighthouse มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “การตรวจติดตามและแจ้งเตือนงบประมาณ”

สร้างระบบตรวจติดตามและแจ้งเตือนอัตโนมัติ เพื่อให้อยู่ภายในงบประมาณประสิทธิภาพที่กำหนดไว้ คุณปฏิบัติ Web Performance Optimization & Lighthouse ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Web Performance Optimization & Lighthouse หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Web Performance Optimization & Lighthouse บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน

บทเรียน “การตรวจติดตามและแจ้งเตือนงบประมาณ” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Web Performance Optimization & Lighthouse นี้ได้ไหม

ได้ บทเรียน Web Performance Optimization & Lighthouse ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. การกำหนดงบประมาณประสิทธิภาพ
  2. การตรวจติดตามและแจ้งเตือนงบประมาณ
  3. เทคโนโลยีประสิทธิภาพที่เกิดขึ้นใหม่
  4. การสื่อสารเรื่องประสิทธิภาพกับผู้มีส่วนได้ส่วนเสีย
← กลับไปที่ Web Performance Optimization & Lighthouse