10 examples of 'wait for jquery to load' in JavaScript

Every line of 'wait for jquery to load' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
139async wait(pageCompleteCheck) {
140 const waitTime = this.options.pageCompleteWaitTime || 5000;
141 if (!pageCompleteCheck) {
142 pageCompleteCheck = this.options.pageCompleteCheckInactivity
143 ? pageCompleteCheckByInactivity
144 : defaultPageCompleteCheck;
145 // if using SPA just override
146 if (this.options.spa) {
147 pageCompleteCheck = spaCheck;
148 }
149 }
150
151 const driver = this.driver,
152 pageCompleteCheckTimeout = this.options.timeouts.pageCompleteCheck;
153 try {
154 const pageCompleteCheckCondition = new Condition(
155 'for page complete check script to return true',
156 function(d) {
157 return d.executeScript(pageCompleteCheck, waitTime).then(function(t) {
158 return t === true;
159 });
160 }
161 );
162 log.debug(
163 `Waiting for script pageCompleteCheck at most ${pageCompleteCheckTimeout} ms`
164 );
165 log.verbose(`Waiting for script ${pageCompleteCheck}`);
166 await timeout(
167 driver.wait(
168 pageCompleteCheckCondition,
169 pageCompleteCheckTimeout,
170 undefined,
171 this.options.pageCompleteCheckPollTimeout || 200
172 ),
173 pageCompleteCheckTimeout,
174 `Running page complete check ${pageCompleteCheck} took too long `
175 );
176 log.debug(`Waiting after load event for ${waitTime} ms.`);
177 await delay(waitTime);
178 } catch (e) {
179 log.error('Failed to wait ' + e);
180 throw new UrlLoadError('Failed to wait ', {
181 cause: e
182 });
183 }
184}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

119return new Promise(function waitForLoaded (resolve) {
120 if (child.hasLoaded) { return resolve(); }
121 child.addEventListener('loaded', resolve);
122});
18function waitUntilLoaded (window, timeout) {
19 var onStopLoading;
20 return Promise.fromNode(function (callback) {
21 onStopLoading = function () {
22 callback(null, window);
23 };
24 window.webContents.on('did-stop-loading', onStopLoading);
25
26 })
27 .timeout(timeout || 60000)
28 .finally(function () {
29 // clean up so we can reuse the window
30 window.webContents.removeListener('did-stop-loading', onStopLoading);
31 })
32 .catch(Promise.TimeoutError, function (err) {
33 window.webContents.stop();
34 throw err;
35 });
36}
41function waitForElement(selector, callback) {
42 if (document.querySelector(selector)) {
43 return callback()
44 } else {
45 setTimeout(waitForElement.bind(this, selector, callback), 300)
46 }
47}
331private async waitForElement(): Promise<void> {
332 if (this.element) {
333 return Promise.resolve();
334 }
335 // tslint:disable-next-line:promise-must-complete
336 return new Promise((resolve) => {
337 this.elementResolve = resolve;
338 });
339}
66(function wait() { setTimeout(wait, 5000) })();
97private _waitTillReady() {
98 this._initialised = true;
99 if (this._hasBeenParsed()) {
100 this._readyCallback();
101 } else {
102 setTimeout(() => {
103 this._waitTillReady();
104 }, 100);
105 }
106}
139function waitForEvents(event)
140{
141 FBTest.sysout("waitForWindowLoad; event: " + event.type + " (" +
142 event.target.location.href + ")");
143
144 if (event.type == "load" && event.target === browser.contentDocument)
145 {
146 browser.removeEventListener("load", waitForEvents, true);
147 loaded = true;
148 }
149 else if (event.type == "MozAfterPaint" && event.target === browser.contentWindow)
150 {
151 browser.removeEventListener("MozAfterPaint", waitForEvents, true);
152 painted = true;
153 }
154
155 // Execute callback after 100ms timeout (the inspector tests need it for now),
156 // but this should be set to 0.
157 if (loaded && painted)
158 setTimeout(executeCallback, 100);
159}
1function jqueryLoaded() {
2 django.jQuery(document).ready(function () {
3 if (!django.hasOwnProperty('unitsList')){
4 django.jQuery.ajax({
5 url: '/api/v1/courses/units',
6 success: function (data, status, jqXHR) {
7 django.unitsList = data
8 }
9 });
10 }
11 });
12}
76function waitForReadyState(element, readyState, interval, done) {
77 var timer = setInterval(function() {
78 if (element.readyState >= readyState) {
79 clearInterval(timer);
80 done(null, true);
81 }
82 }, interval);
83}

Related snippets