تقليل حجم الحزمة والبصمة على القرص
قلّل حجم مُثبّت تطبيق Electron وحجمه على القرص عبر تقليص التبعيات، واستخدام ASAR، وحذف الملفات غير المستخدمة، بما يكمل تحسينات بدء التشغيل والذاكرة.
تقليل حجم الحزمة والبصمة على القرص درس مجاني في Electron Desktop App Development على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Electron Desktop App Development، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Electron Desktop App Development 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
The Size Problem
Electron apps ship a full Chromium runtime, so they start large. Keeping your code and assets lean is what you can control.
Audit Your Dependencies
Every dependency ships with your app. devDependencies do not. Misplacing a build tool bloats the bundle.
function shipsInApp(dep) {
return dep.type === 'dependency';
}
console.log(shipsInApp({ name: 'lodash', type: 'dependency' }));Prune node_modules
Packagers can run npm prune --production to strip dev packages before bundling.
Use ASAR Archiving
ASAR packs your app files into a single archive, reducing file count and speeding reads.
{
"build": {
"asar": true
}
}Exclude Unneeded Files
Use packager files globs to exclude tests, docs, and source maps from the shipped app.
function include(path) {
return !path.includes('/test/') && !path.endsWith('.map');
}
console.log(include('src/test/spec.js'));Tree-Shake the Renderer
Bundle renderer code with a tool that tree-shakes dead code, and import only what you use.
// good: import only one function
// import { debounce } from 'lodash-es';Prefer Lightweight Libraries
Swap heavy packages for smaller alternatives. A date helper may replace a multi-megabyte library.
Compress Assets
Optimize images and fonts. Use modern formats and subset fonts to only the glyphs you ship.
Native Module Costs
Native modules add platform-specific binaries. Include only the ones you truly need to avoid per-arch bloat.
Measure the Result
Inspect the unpacked app size and installer size before and after changes to confirm real savings.
function deltaMB(before, after) {
return (before - after).toFixed(1) + ' MB saved';
}
console.log(deltaMB(180.4, 142.1));Differential Updates
Smaller bundles also mean smaller delta updates, so users download less on each release.
Quick Check
Test your footprint optimization knowledge.
Recap
You learned to shrink your app: audit and prune dependencies, enable ASAR, exclude unneeded files, tree-shake, compress assets, mind native modules, and measure the savings.
الأسئلة الشائعة
هل درس «تقليل حجم الحزمة والبصمة على القرص» مجاني؟
نعم — نص درس «تقليل حجم الحزمة والبصمة على القرص» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Electron Desktop App Development، انتقل إلى CoddyKit PRO. تتضمن دورة Electron Desktop App Development 4 دروس في المجموع.
ماذا ستتعلم في «تقليل حجم الحزمة والبصمة على القرص»؟
قلّل حجم مُثبّت تطبيق Electron وحجمه على القرص عبر تقليص التبعيات، واستخدام ASAR، وحذف الملفات غير المستخدمة، بما يكمل تحسينات بدء التشغيل والذاكرة. تتمرن على Electron Desktop App Development مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Electron Desktop App Development؟
لا تُشترط خبرة سابقة. Electron Desktop App Development على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «تقليل حجم الحزمة والبصمة على القرص»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Electron Desktop App Development هذا؟
نعم. كل درس في Electron Desktop App Development يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- تحسين وقت بدء التشغيل
- تقنيات إدارة الذاكرة
- تحليل الأداء
- تقليل حجم الحزمة والبصمة على القرص