Home Web Front-end JS Tutorial Which one is executed first, ready or load? What is the difference between ready and load events in jquery?

Which one is executed first, ready or load? What is the difference between ready and load events in jquery?

Oct 29, 2018 pm 04:46 PM
load implement

Which one executes first, ready or load? I believe that many friends who have just come into contact with jquery will have such questions. This chapter will introduce to you who is executed first, ready or load? The difference between ready and load events in jquery. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Which one is executed first, ready or load? What is the difference between ready and load events in jquery?

Which one executes first, ready or load:

During the interview process, we are often asked a question: which one executes first, ready or load? , which one is executed after? The answer is that ready is executed first and load is executed later.

The steps for loading a DOM document:

To understand why ready is executed first and then load is executed, you must understand the steps for loading a DOM document:

(1) Parse the HTML structure .

(2) Load external scripts and style sheet files.

(3) Parse and execute script code.

(4) Construct HTML DOM model. //ready

(5) Load external files such as images.

(6) The page is loaded. //load

It can be understood from the execution steps of a document that ready starts execution after [step 4] is completed, while load starts execution after [step 6] is completed

ready event:

The ready event is executed after the DOM structure is drawn. This ensures that even if a large number of media files are not loaded, the JS code can still be executed.

load event: The

load event must wait until all content in the web page is loaded before it is executed. If there are a large number of images in a web page, this situation will occur: the web page document has been rendered, but because the web page data has not been completely loaded, the load event cannot be triggered immediately.

Summary:

I believe everyone already understands the difference between ready and load. In fact, if there are no media files such as pictures in the page, ready and load are almost the same, but there are files in the page. It's different, so I still recommend everyone to use ready at work.

The above is how to layout the flexbox flexible box? Full introduction to the detailed tutorial, if you want to know more about jQuery, please pay attention to the PHP Chinese website.


The above is the detailed content of Which one is executed first, ready or load? What is the difference between ready and load events in jquery?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Python script to be executed every 5 minutes Python script to be executed every 5 minutes Sep 10, 2023 pm 03:33 PM

Automation and task scheduling play a vital role in streamlining repetitive tasks in software development. Imagine there is a Python script that needs to be executed every 5 minutes, such as getting data from an API, performing data processing, or sending periodic updates. Running scripts manually so frequently can be time-consuming and error-prone. This is where task scheduling comes in. In this blog post, we will explore how to schedule a Python script to execute every 5 minutes, ensuring it runs automatically without manual intervention. We will discuss different methods and libraries that can be used to achieve this goal, allowing you to automate tasks efficiently. An easy way to run a Python script every 5 minutes using the time.sleep() function is to utilize tim

How to use Python for scripting and execution in Linux How to use Python for scripting and execution in Linux Oct 05, 2023 am 11:45 AM

How to use Python to write and execute scripts in Linux In the Linux operating system, we can use Python to write and execute various scripts. Python is a concise and powerful programming language that provides a wealth of libraries and tools to make scripting easier and more efficient. Below we will introduce the basic steps of how to use Python for script writing and execution in Linux, and provide some specific code examples to help you better understand and use it. Install Python

How to perform Brown-Forsythe test in Python How to perform Brown-Forsythe test in Python Aug 31, 2023 pm 11:53 PM

The Brown-Forsythe test is a statistical test used to determine whether the variances of two or more groups are equal. Levene's test uses the absolute deviation from the mean, while the Brown-Forsythe test uses the deviation from the median. The null hypothesis used in the test is as follows - H0: The variances of the groups (population) are equal. The alternative hypothesis is that the variances of the groups (population) are not equal. - H1: The variances of the groups (population) are not equal. To perform the test, we calculate the median of each group and its correlation The absolute deviation of the number of digits. We then calculate the F-statistic based on the variance of these deviations. Assume that the calculated F statistic is greater than the critical value in the F distribution table. In this case, we reject the null hypothesis and conclude that the variances of the groups are not equal. In Python, sc

How to write PHP code in the browser and keep the code from being executed? How to write PHP code in the browser and keep the code from being executed? Mar 10, 2024 pm 02:27 PM

How to write PHP code in the browser and keep the code from being executed? With the popularization of the Internet, more and more people have begun to come into contact with web development, and learning PHP has also attracted more and more attention. PHP is a scripting language that runs on the server side and is often used to write dynamic web pages. However, during the exercise phase, we want to be able to write PHP code in the browser and see the results, but we don't want the code to be executed. So, how to write PHP code in the browser and keep it from being executed? This will be described in detail below. first,

How to perform ANCOVA in Python? How to perform ANCOVA in Python? Sep 01, 2023 pm 05:21 PM

ANCOVA (analysis of covariance) is a useful statistical method because it allows the inclusion of covariates in the analysis, which can help adjust for auxiliary variables and increase the precision of comparisons between groups. These additional factors or covariates can be included in the study by using ANCOVA. To ensure that observed differences between groups are caused by the treatment or intervention in the study and not by extraneous factors, ANCOVA can be used to adjust for the effect of covariates on the group means. This allows for more accurate comparisons between groups and gives more reliable conclusions about the relationships between variables. In this article, we will take a closer look at ANCOVA and implement it in Python. What is ANCOVA? Analysis of covariance (ANCOVA) method compares two or more groups

How to deal with .sh file execution problems in Linux environment? How to deal with .sh file execution problems in Linux environment? Mar 14, 2024 pm 03:36 PM

In the Linux environment, we often encounter situations where we need to execute .sh files. The .sh file is a script file in the Linux system, usually with .sh as the suffix, used to execute a series of commands. But sometimes we may encounter the problem that the .sh file cannot be executed. This may be due to permission issues or encoding format and other reasons. This article will introduce how to deal with .sh file execution issues in a Linux environment and provide specific code examples. 1. Add execution permissions in Linux system if a.

What to do if mysql load data is garbled? What to do if mysql load data is garbled? Feb 16, 2023 am 10:37 AM

The solution to the garbled mysql load data: 1. Find the SQL statement with garbled characters; 2. Modify the statement to "LOAD DATA LOCAL INFILE "employee.txt" INTO TABLE EMPLOYEE character set utf8;".

Execute if and else statements simultaneously in C/C++ Execute if and else statements simultaneously in C/C++ Sep 05, 2023 pm 02:29 PM

In this section, we will see how to execute both if and else parts in C or C++ code. This solution is a bit tricky. When if and else are executed one after another, it is as if the statement without if-else was executed. But here we will see how to execute them sequentially if they exist. Sample code #include<iostream>usingnamespacestd;intmain(){ intx=10; if(x>5) { &

See all articles