← Back to guillaumepotier/Parsley.js

How to Deploy & Use guillaumepotier/Parsley.js

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

  1. Clone the repository:
git clone https://github.com/guillaumepotier/Parsley.js.git
  1. Navigate to the project directory:
cd Parsley.js
  1. 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

  1. Install development dependencies:
npm install -g gulp
npm install
  1. Run tests:
gulp test
  1. Build the project:
gulp build

Running Tests

  • In the browser: Run a server with gulp test-browser, then open test/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

  1. jQuery Version Compatibility

    • Issue: Using jQuery version below 1.8
    • Solution: Upgrade to jQuery >= 1.8
  2. 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>
    
  3. 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
  4. Custom Validators Not Working

    • Issue: Custom validation rules not being applied
    • Solution: Verify that custom validators are registered before the form loads

Getting Help

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