{"_id":"@benjaminreid/ready.js","_rev":"3-f0e197c933fdca3915ca2c785e03c5bb","name":"@benjaminreid/ready.js","description":"Takes the pain out of writing conditional initialisation code","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.2":{"name":"@benjaminreid/ready.js","version":"0.1.2","filename":"ready.min.js","description":"Takes the pain out of writing conditional initialisation code","main":"dist/ready.js","repository":{"type":"git","url":"https://github.com/nouveller/ready.js.git"},"keywords":["ready","dry","initialisation"],"author":{"name":"Benjamin Reid","email":"benjaminreid.nouveller@gmail.com","url":"http://nouveller.com"},"license":"MIT","bugs":{"url":"https://github.com/nouveller/ready.js/issues"},"homepage":"https://github.com/nouveller/ready.js","devDependencies":{"gulp":"^3.8.11","gulp-release-tasks":"0.0.3","gulp-rename":"^1.2.2","gulp-uglify":"^1.2.0"},"autoupdate":{"source":"git","target":"git://github.com/nouveller/ready.js.git","basePath":"dist/","files":["ready.min.js","ready.js"]},"gitHead":"29b75b6eab8a5cb2667ccf845c76de2171c45e83","_id":"@benjaminreid/ready.js@0.1.2","scripts":{},"_shasum":"5f925f5bd2db652ef68bdc2a4e33f197aeb02fad","_from":".","_npmVersion":"2.6.0","_nodeVersion":"0.10.36","_npmUser":{"name":"benjaminreid","email":"benjaminreid.nouveller@gmail.com"},"dist":{"shasum":"5f925f5bd2db652ef68bdc2a4e33f197aeb02fad","tarball":"https://registry.npmjs.org/@benjaminreid/ready.js/-/ready.js-0.1.2.tgz","integrity":"sha512-W/5DH9SunIkWLiiHUym7fuZ2XdEkEB/IxDTo0PMU8bPTkcj80y6Mo6o+h+xOvWDqQ93JhK4fodBbFUYCdLtgNw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDxoB42H0HwZ6UtqQ9nNI2O4FpkaGD5UAChs8aFDuzBbwIgdhVb70zlEyQwLkBhxbttm2anKhnOEyJ6I/Ev49DsRdU="}]},"maintainers":[{"name":"benjaminreid","email":"benjaminreid.nouveller@gmail.com"}]}},"readme":"# ready.js\nTakes the pain out of writing conditional initialisation code.\n\n## Contents\n* [Installation](#installation)\n* [What does ready.js do?](#what-does-readyjs-do)\n* [Demo](#demo)\n* [Coming soon](#coming-soon)\n* [TL;DR](#tldr)\n\n## Installation\n\n### Bower\n\n`ready.js` is available as a Bower package and can be installed with the following command.\n\n```\nbower install --save ready.js\n```\n\nIf you're using [ck86/main-bower-files](https://github.com/ck86/main-bower-files) to automatically load in packages from Bower in your build process, that's covered too.\n\n### Manually\n\nYou can also install `ready.js` manually by grabbing the contents of `dist/ready.js` or `dist/ready.min.js` and including them above your main JavaScript file in your page. It has no dependencies so as long as it's loaded before your first `ready` call, you're good to go. \n\n```\n<script src=\"/path/to/ready.js\"><script>\n<script src=\"/path/to/main.js\"></script>\n```\n\n### CDNJS\n\n`ready.js` is also available cdnjs, [grab it here](https://cdnjs.com/libraries/ready.js).\n\n## What does ready.js do?\n\n`ready.js` gives you a simple way to ~~pretty~~ DRY up your initialisation code. Take this piece of code for example.\n\n```\nvar foo  = document.getElementById('foo');\nvar bar  = document.getElementById('foo');\nvar bazs = document.getElementsByClassName('bazs');\n\nif (foo.length > 0) {\n  // do something with foo\n}\n\nif (bar.length > 0) {\n  // do something with bar\n}\n\nif (bazs.length > 0) {\n  for(var i = 0; i < bazs.length; i++) {\n    var baz = elements[i];\n    // do something with baz\n  }\n}\n```\n\nThis is a fairly common pattern to see, you attempt to grab an element from the DOM and then do something with it if it exists. `ready.js` removes this boilerplate code you write each time you want to do this.\n\n```\nready('#foo', function(foo) {\n  // do something with foo\n});\n\nready('#bar', function(bar) {\n  // do something with bar\n});\n\nready('.bazs', function(baz) {\n  // do something with baz\n});\n```\n\n`ready.js` will get the DOM elements for you, check if they exist, and if so, fire your initialisation code in it's callback. It can handle a single element or a collection of elements too.\n\n## Demo\n\n[View the demo on Codepen](http://codepen.io/nouveller/pen/gpPJzw).\n\n## Coming soon\n\nPlease check the [v1.0 release](https://github.com/nouveller/ready.js/milestones/v1.0%20release) milestone for things to come.\n\n## TL;DR\n\nWhen you're not using `ready.js`.\n\n![Not ready](https://cloud.githubusercontent.com/assets/713128/7526823/5a376a48-f50d-11e4-90c2-3e41c1849aef.gif)\n","maintainers":[{"name":"benjaminreid","email":"benjaminreid.nouveller@gmail.com"}],"time":{"modified":"2022-06-12T15:10:50.950Z","created":"2015-05-14T09:07:28.041Z","0.1.2":"2015-05-14T09:07:28.041Z"},"homepage":"https://github.com/nouveller/ready.js","keywords":["ready","dry","initialisation"],"repository":{"type":"git","url":"https://github.com/nouveller/ready.js.git"},"author":{"name":"Benjamin Reid","email":"benjaminreid.nouveller@gmail.com","url":"http://nouveller.com"},"bugs":{"url":"https://github.com/nouveller/ready.js/issues"},"license":"MIT","readmeFilename":"README.md"}