Parsley.js Deployment and Usage Guide
Prerequisites
- Runtime Requirements:
- jQuery >= 1.8 (compatible with 2.x and 3.0)
- es5-shim if you need to support IE8
- Development Tools:
- Node.js and npm (for building and testing)
- Gulp (installed globally)
Installation
Using npm
npm install parsleyjs
Using Bower
bower install parsleyjs
Manual Download
- Clone the repository:
git clone https://github.com/guillaumepotier/Parsley.js.git
- Navigate to the project directory:
cd Parsley.js
- Install dependencies:
npm install
Configuration
Basic Setup
Include the required libraries in your HTML:
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.10/es5-shim.min.js"></script>
<script src="path/to/parsley.min.js"></script>
Form Integration
Add the data-parsley-validate attribute to your form:
<form id="myForm" data-parsley-validate>
<!-- form fields -->
</form>
Build & Run
Development Environment
- Install development dependencies:
npm install -g gulp
npm install
- Run tests:
gulp test
- Build the project:
gulp build
Running Tests
- In the browser: Run a server with
gulp test-browser, then opentest/runner.html - In the terminal:
gulp test
Deployment
Static Hosting
Since Parsley.js is a frontend library, you can deploy it on any static hosting platform:
- GitHub Pages - Perfect for documentation sites
- Netlify - Free static hosting with continuous deployment
- Vercel - Excellent for frontend applications
- AWS S3 with CloudFront - For enterprise-level static hosting
Integration with Web Frameworks
Parsley.js integrates with various frameworks. For framework-specific integrations, check the integrations section in the README.
Troubleshooting
Common Issues
-
jQuery Version Compatibility
- Issue: Using jQuery version below 1.8
- Solution: Upgrade to jQuery >= 1.8
-
IE8 Support
- Issue: Form validation not working in IE8
- Solution: Include es5-shim:
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.10/es5-shim.min.js"></script> -
Form Not Validating
- Issue: Form doesn't validate even with data-parsley-validate attribute
- Solution: Ensure jQuery is loaded before Parsley.js and check console for errors
-
Custom Validators Not Working
- Issue: Custom validation rules not being applied
- Solution: Verify that custom validators are registered before the form loads
Getting Help
- Questions: Ask on StackOverflow with the
parsley.jstag - Bug Reports: Check the CONTRIBUTING.md file
- Examples: Start from this jsfiddle for reference implementations
Performance Tips
- Use minified versions (
parsley.min.js) in production - Only include the validators you need to reduce bundle size
- Consider tree-shaking if using a module bundler