Skip to content
the poor coder

deny ready jquery

Poor Man
Published
Reading time
1 min read
On this page

Deny Ready jQuery in HTML#

Denying the Ready jQuery function in HTML can be useful in certain circumstances where you want to prevent the execution of a script until a certain event occurs. Here's how you can do it:

Option 1: Using a Boolean Variable#

You can create a boolean variable to keep track of whether the document is ready or not. Once the document is ready, you can set the variable to true and execute your script accordingly.

Text

var isDocReady = false;

$(document).ready(function() {
  isDocReady = true;
});

if (isDocReady) {
  // Execute your script here
}

Option 2: Using the onload Event#

You can also use the onload event to ensure that your script doesn't execute until all resources on the page have finished loading. Here's how you can do it:

Text

window.onload = function() {
  // Execute your script here
};

Option 3: Using Deferred Objects#

If you're using jQuery, you can use Deferred objects to ensure that your script doesn't execute until certain events have occurred. Here's an example:

Text

$.when($.ready, $.ajax("/my-script.js")).done(function() {
  // Execute your script here
});

The above code waits for both the document to be ready and for an AJAX request to complete before executing the script.

Keep going

2023

how to sort an array

How to Sort an Array If you have an array and you want to order its elements in a specific way, you need to use a sorting algorithm. There are several sorting algorithms available, but two of the most commonly used are…

javascript2 min read
2023

jquery mobile or desktop

jQuery Mobile or Desktop? As a web developer, I have had some experience with both jQuery Mobile and jQuery Desktop. Both frameworks have their pros and cons, and which one to use really depends on the specific project…

javascript1 min read
2023

node.js folder structure

Node.js Folder Structure If you are new to Node.js, it can be daunting to create a folder structure that will work for your project. The structure you choose will depend on the size and complexity of your project. Here…

javascript1 min read
ESC