Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/johansatge/jquery-notready

A lightweight script that allows you to make use of jQuery(document).ready before jQuery loads.
https://github.com/johansatge/jquery-notready

javascript jquery

Last synced: 17 days ago
JSON representation

A lightweight script that allows you to make use of jQuery(document).ready before jQuery loads.

Awesome Lists containing this project

README

        

# jQuery notReady

A lightweight script that allows you to make use of `jQuery(document).ready` before jQuery loads.

---

* [Why](#why)
* [Installation](#installation)
* [Usage](#usage)
* [Changelog](#changelog)
* [License](#license)

## Why

Let's consider that your webpage needs to call jQuery stuff when the DOM is ready, by using this common syntax:

```html

jQuery(document).ready(function($)
{
$('.my-div').jQueryStuff();
});

```

This code needs jQuery to be loaded first. This is a problem as JS files should be loaded at the bottom of the page.

The `jquery.notready` script solves it by declaring a fake jQuery object that you can use everywhere on the page, and that will be replaced by the real one when it is propery loaded.

*Using jQuery calls in the HTML documents may not be a good thing, but in some cases it has to be done this way - this tool provides a workaround for those specific cases.*

## Installation

```bash
bower install jquery.notready
```

Alternatively, you may manually install the `jquery.notready.min.js` and `jquery.ready.min.js` scripts wherever you want in your project.

Then, call the first script in ``:

```html

```

And the second one next to the jQuery call, at the bottom of the page:

```html