This document describes how to use the package manager (npm) for development tasks.
- Node.js 14.0.0 or higher
- npm (comes with Node.js)
Install development dependencies:
npm installCheck code for potential issues:
npm run lintAutomatically fix linting issues where possible:
npm run lint:fixCheck code formatting (JavaScript files only):
npm run format:checkFormat JavaScript files:
npm run formatNote: The existing codebase uses its original formatting style. Prettier and ESLint are provided as optional tools for new code or improvements.
Run all checks (formatting and linting):
npm run validateCurrently, there are no automated tests configured:
npm run testBuild Docker images:
npm run docker:build # Standard Debian-based image
npm run docker:build-alpine # Alpine-based imageThe package manager setup includes:
- ESLint: JavaScript linting tool to catch common errors
- Prettier: Code formatting tool to maintain consistent style
These tools are configured but non-intrusive to the existing codebase.
.
├── speedtest.js # Main speedtest library
├── speedtest_worker.js # Web Worker for speed testing
├── index.html # Default UI
├── backend/ # PHP backend files
├── examples/ # Example implementations
├── results/ # Results/telemetry handling
├── docker/ # Docker-related files
└── package.json # npm package configuration
The package manager provides several benefits:
- Standardized tooling: Common commands across different environments
- Development dependencies: Easy installation of linting and formatting tools
- Project metadata: Version, description, and licensing information
- Future extensibility: Foundation for adding build tools, tests, or bundlers if needed
- npm distribution: Makes the library easy to use in other Node.js projects
When making changes:
- Run
npm run lintto check for potential issues - Consider running
npm run formaton new files for consistency - Test your changes manually in a browser
- For PHP backend changes, test with the appropriate server setup
- The core library has no runtime dependencies - it's pure vanilla JavaScript
- Development dependencies (ESLint, Prettier) are only needed for development
- The library can still be used standalone without npm (just include the JS files)
- npm setup is completely optional and doesn't change how the library is deployed