The plugin provides an easy way to implement a cookie consent banner to your website. The messages are easily customisable and new language translations can be added. This is a lightweight version of the cookie consent, for large companies they might need the "Edit preferences" option to let the user customize what he wants to accept/reject. Additional languages can be added by using the settings. Note that jQuery serialcookie is shared for inspirational and development purpose.
See the project page for a demonstration.
jQuery serialcookie has been tested in: IE, Edge, Chrome (mobile included), Firefox (mobile included), and Safari (mobile included).
Download and save one of two available files to include serialcookie to your page, either the development or the minified version. Also, you can visit the project page to copy what you need.
<script src="jquery.serialcookie.min.js"></script>
<link href="jquery.serialcookie.css" rel="stylesheet">
Due to the lightweight CSS code, it's recommended to copy/paste the CSS code into your general stylesheet.
Make sure jQuery is properly loaded before using jQuery serialcookie.
The basic usage of serialcookie is pretty easy, just start using jQuery serialcookie by calling it after page load.
$(document).ready(function(){
// jquery.serialcookie initialisation
$.serialcookie({
callback: function(isAccepted){
if( isAccepted ){
// Google Analytics
console.log('Loading Google Analytics script..');
}
}
});
});
The following configurations is available by default:
Name | Type | Default | Description |
---|---|---|---|
lanug | string | 'auto' | The autodetection is based on the LANG attribute of the HTML tag |
callback | function | 'function(isAccepted){}' | Essential fn to call the script that are using cookies |
template | string | See jquery.serialcookie.js | The HTML template where the translations will be injected |
translations | object | See jquery.serialcookie.js | The translations in each language |
Please report bugs and feel free to ask for new features directly on GitHub.
jQuery serialcookie is licensed under MIT license.