An extensible JavaScript plugin for site-builders like Squarespace to easily create an age-gate for free.
For Squarespace or other site-builder usage, see below.
- Add script to your website JavaScript.
- On page ready, call
new Agegate
, passing in your options:
new Agegate({
cancelUrl: 'https://nicknish.co'
})
- Go to Settings.
- Under the Website category, find Advanced.
- Go to Code Injection. This is where you can add custom scripts to your Squarespace website.
- Scroll to Footer.
- Click this link, copy the contents of the script, then paste it between two
<script>
HTML tags.
<script>
// POPUP.MIN.JS SCRIPT GOES HERE
</script>
- Then, before the
</script>
tag, right after the code you copied, add this:
<script>
// POPUP.MIN.JS SCRIPT GOES HERE
(function(window) {
function ready(fn) {
if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading"){
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
ready(function() {
new Agegate({
cancelUrl: 'https://nicknish.co' // This is where your user will be taken if they do not agree to the popup
});
})
}(window));
</script>
Create tutorial to add this to your Squarespace or site-builder website.- Add note about adding CSS from
popup.css
. - Update demo to be able to reset the popup cookie.
- Add notes about dependencies, file size, and supported browsers.
- Add Webpack to handle a lot of the heavy-loading and maintenance of this repo.
Create a new issue here.