จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Closure Compiler คืออะไร
Closure Compiler เป็นเครื่องมือที่ช่วยให้ดาวน์โหลดและเรียกใช้ JavaScript ได้เร็วขึ้น
โดยจะคอมไพล์จาก JavaScript เป็น JavaScript ที่ดีขึ้นแทนที่จะคอมไพล์จากภาษาต้นฉบับเป็นโค้ดเครื่อง โดยจะแยกวิเคราะห์ JavaScript วิเคราะห์โค้ดดังกล่าว นำโค้ดที่ไม่ได้ใช้งานออก แล้วเขียนใหม่และลดขนาดโค้ดที่เหลือ นอกจากนี้ยังตรวจสอบ
ไวยากรณ์ การอ้างอิงตัวแปร และประเภทต่างๆ รวมถึงเตือนเกี่ยวกับข้อควรระวังทั่วไป
ของ JavaScript
ฉันจะใช้ Closure Compiler ได้อย่างไร
คุณใช้ Closure Compiler ได้ดังนี้
แอปพลิเคชัน Java แบบโอเพนซอร์สที่คุณเรียกใช้ได้จากบรรทัดคำสั่ง
ไลบรารีที่คุณใช้ได้ผ่าน Bazel
แพ็กเกจ NPM
หากต้องการเริ่มต้นใช้งานคอมไพเลอร์ โปรดดู "ฉันจะเริ่มต้นใช้งานอย่างไร" ด้านล่าง
การใช้ Closure Compiler มีประโยชน์อย่างไร
ประสิทธิภาพ Closure Compiler จะลดขนาดไฟล์ JavaScript และทำให้มีประสิทธิภาพมากขึ้น ซึ่งจะช่วยให้แอปพลิเคชันโหลดได้เร็วขึ้นและลดความต้องการแบนด์วิดท์
การตรวจสอบโค้ด Closure Compiler จะแสดงคำเตือน
สำหรับ JavaScript ที่ผิดกฎหมายและคำเตือนสำหรับการดำเนินการที่อาจเป็นอันตราย
ซึ่งจะช่วยให้คุณสร้าง JavaScript ที่มีข้อบกพร่องน้อยลงและ
ดูแลรักษาง่ายขึ้น
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eThe Closure Compiler is a tool that optimizes JavaScript for faster download and execution by analyzing, removing dead code, and minimizing the remaining code.\u003c/p\u003e\n"],["\u003cp\u003eIt offers benefits such as improved efficiency by reducing file size and enhanced code checking by providing warnings for potential issues.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can utilize the Closure Compiler through a command-line application, a simple web interface, or by integrating it into their development workflow via the provided resources and documentation.\u003c/p\u003e\n"]]],[],null,["What is the Closure Compiler?\n\n\nThe Closure Compiler is a tool for making JavaScript download and run\nfaster. Instead of compiling\nfrom a source language to machine code, it compiles from JavaScript to\nbetter JavaScript. It parses your JavaScript, analyzes it, removes\ndead code and rewrites and minimizes what's left. It also checks\nsyntax, variable references, and types, and warns about common\nJavaScript pitfalls.\n\nHow can I use the Closure Compiler?\n\n\nYou can use the Closure Compiler as:\n- An open source Java application that you can run from the command line.\n- A library you can depend on via Bazel.\n- An NPM package\n- To get started with the compiler, see \"How do I start\" below.\n\nWhat are the benefits of using Closure Compiler?\n - **Efficiency.** The Closure Compiler reduces the size of\n your JavaScript files and makes them more efficient, helping your\n application to load faster and reducing your bandwidth needs.\n\n - **Code checking.** The Closure Compiler provides warnings\n for illegal JavaScript and warnings for potentially dangerous\n operations, helping you to produce JavaScript that is less buggy and\n easier to maintain.\n\n How do I start?\n\n\n - Download the most recently released JAR file from the [Maven repository](https://mvnrepository.com/artifact/com.google.javascript/closure-compiler).\n - Work through the [Application\n Hello World](/closure/compiler/docs/gettingstarted_app).\n - Read about [Advanced\n compilation](/closure/compiler/docs/api-tutorial3).\n - Explore [the project's source code](https://github.com/google/closure-compiler).\n\n \u003cbr /\u003e"]]