{"id":16690805,"url":"https://github.com/omaxel/just-wait","last_synced_at":"2026-04-29T17:03:35.450Z","repository":{"id":42236386,"uuid":"137228163","full_name":"omaxel/Just-Wait","owner":"omaxel","description":"A lightweight jQuery Ajax util library.","archived":false,"fork":false,"pushed_at":"2023-01-06T01:33:58.000Z","size":1173,"stargazers_count":2,"open_issues_count":7,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T03:26:24.740Z","etag":null,"topics":["jquery","jquery-ajax","jquery-library","jqxhr"],"latest_commit_sha":null,"homepage":"https://omaxel.github.io/Just-Wait/","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/omaxel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-13T14:37:01.000Z","updated_at":"2022-06-22T07:39:26.000Z","dependencies_parsed_at":"2023-02-05T01:32:00.327Z","dependency_job_id":null,"html_url":"https://github.com/omaxel/Just-Wait","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/omaxel/Just-Wait","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaxel%2FJust-Wait","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaxel%2FJust-Wait/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaxel%2FJust-Wait/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaxel%2FJust-Wait/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omaxel","download_url":"https://codeload.github.com/omaxel/Just-Wait/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaxel%2FJust-Wait/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32435122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T13:34:34.882Z","status":"ssl_error","status_checked_at":"2026-04-29T13:34:29.830Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jquery","jquery-ajax","jquery-library","jqxhr"],"created_at":"2024-10-12T16:05:31.641Z","updated_at":"2026-04-29T17:03:35.435Z","avatar_url":"https://github.com/omaxel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Just Wait\nWait what? The server response.\n\n[Just Wait](https://github.com/OmarMuscatello/Just-Wait) is a lightweight jQuery utility that allows you to specify a function to be executed after a specified amount of time from the start of the AJAX request. If the AJAX request ends before the specified amount of time, the function will never be executed.\n\nNot clear? **Try the [**TEST TOOL**](https://omarmuscatello.github.io/Just-Wait/)**.\n\n## Quick start\n-  Add the `just-wait.min.js` file to your page.\n   ```\n   \u003cscript src=\"just-wait.min.js\"\u003e\u003c/script\u003e\n   ```\n-  *[Optional]* Adjust the `waitFor` parameter using `JustWait.options.waitFor` (see [Time adjusting](#time-adjusting)).\n-  Add a `wait` call back to the jqXHR object.\n   Example:\n   ```\n    $.get('url') // or $.getJSON, $.post, $.getScript, $.load, $.ajax\n        .wait(() =\u003e { // \u003c======= Wait callback\n            \n        })\n        .done((data) =\u003e { ... })\n        .fail(() =\u003e { ... })\n        .always(() =\u003e { \n            // The AJAX request ends. Hide the loader.\n            $loader.hide();\n        });\n   ```\n- *[Optional]* Adjust the `waitFor` parameter only for a single request:\n   ```\n  $.get({ url: 'url', waitFor: 500 }) // or $.getJSON, $.post, $.getScript, $.load, $.ajax\n        .wait(() =\u003e {\n            \n        })\n        .done((data) =\u003e { ... })\n        .fail(() =\u003e { ... })\n        .always(() =\u003e { \n            // The AJAX request ends. Hide the loader.\n            $loader.hide();\n        });\n   ```\n\n## Explanation\nSuppose you have to display a loader while doing an AJAX request. I'm sure you are using a code similar to\n\n```\n$loader.show(); // Show the loader before starting the AJAX request\n\n$.get('url') // or $.post or $.ajax\n    .done((data) =\u003e { ... })\n    .fail(() =\u003e { ... })\n    .always(() =\u003e { \n        // The AJAX request ends. Hide the loader.\n        $loader.hide();\n    });\n```\n\nOf course, this is good: the user will see a loader while waiting for the server response. But, if the response is returned almost immediately the user will see a fast show/hide of the loader (aka flickering). You don't want that.\n\n[**Just Wait**](https://github.com/OmarMuscatello/Just-Wait) solves this problem. It allows you to specify a function to be executed after a specified amount of time from the start of the AJAX request. If the AJAX request ends before the specified amount of time, the function will never be executed.\nSo, the previous code could be written as:\n\n```\n\n$.get('url') // or $.post or $.ajax\n    .wait(() =\u003e {\n        // Show the loader after 100ms (default), if the request doesn't end before.\n        $loader.show();\n    })\n    .done((data) =\u003e { ... })\n    .fail(() =\u003e { ... })\n    .always(() =\u003e { \n        // The AJAX request ends. Hide the loader.\n        $loader.hide();\n    });\n```\n\nSee the below timeline to better understand how it works.\n\n![Just Wait diagram](https://github.com/OmarMuscatello/Just-Wait/blob/master/resources/justwait-diagram.svg)\n\n## Time adjusting\nYou can globally specify the amount of time to wait before the `wait` callback is executed by using the following code. Ensure that the code below is executed before any use of the `wait` callback.\n\n```\nJustWait.options.waitFor = 100; // Default 100ms\n```\n\nYou can also specify the `waitFor` option for every request:\n```\n$.ajax({\n        url: 'url',\n        ...\n        waitFor: 500 // ms\n    })\n    ...\n```\nor\n```\n$.get({\n        url: 'url',\n        ...\n        waitFor: 500 // ms\n    })\n    ...\n```\nor\n```\n$.post({\n        url: 'url',\n        data: { id: 5 }\n        ...\n        waitFor: 500 // ms\n    })\n    ...\n```\nor [any shorthand for $.ajax](https://api.jquery.com/category/ajax/shorthand-methods/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomaxel%2Fjust-wait","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomaxel%2Fjust-wait","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomaxel%2Fjust-wait/lists"}