


Discuss the loading order of html and javascript in the browser_javascript skills
I swept through JavaScript a while ago, and I felt good about myself at the time. Now that I think about it, I feel like it’s nothing. Today's task is to study the chapter on the life cycle of the client page in asp.net ajax. However, I was a bit confused by the content of this chapter. None of these doubts are mentioned in the book.
1. What is the detailed loading process of html page? What is the priority of page elements when loading?
2. The scope of JavaScript, the scope of variables, and the relationship between different script segments?
3. The life cycle of html pages?
These questions really hit home for me. Without understanding these, I cannot see the underlying principles through the asp.net ajax framework. I only know it but don't know why.
With extensive access to information online. Got some answers.
About html loading:
Generally speaking, html is loaded and parsed in order from top to bottom, while generating dom objects. As for what is mixed in html:
document.write("xxxx");
and the like, what is their order? Still the same, if you encounter these things when parsing HTML, you will stop parsing and execute these generated statements. If an external link is inserted in the middle, you will parse and execute the js corresponding to the external link. The following statements have different results for different browsers:
In ie. It will not wait for aaa.js to be downloaded and parsed. It will create another thread to handle it, and the main thread will pass over. But in ff. It will wait until aaa.js is downloaded, parsed, and executed.
Regarding the execution of javascript, please see the reference materials attached at the end of this article, which has a detailed discussion.
About the life cycle of pages in html:
The two most important events are onLoad and onUnLoad. onLoad is triggered when the page is loaded. onUnLoad is triggered after the DOM of the page is destroyed. However, onLoad is a bit special, please also see the reference materials attached at the end of this article. Be sure to draw attention.
I looked at the html source code of several sites and found the following code:
This is the code for a website to display advertisements on the page. On domestic websites, display advertisements usually use iframes to introduce third-party pages, but here they are generated directly using javascript segments. Later, I looked at the html code generated by the 163 blog. It was so abnormal. The entire html code has only one shelf, and all pages are generated through js. I saw that several js files were introduced behind the page, and finally there was a call to the initAll function at the end of the page. I haven't studied its js code carefully. I suspect that it puts all the functions of the presentation layer into the client's js file. The server side is just a few page racks and many webservices. It's really breathtaking.
About one event triggering multiple response functions:
I once thought about implementing something similar to a delegate in c#. JavaScript events can be associated with more than one function. A list of events can be triggered at a time. I have been studying asp.net ajax these days and there is a package for this.
In asp.net ajax, a dom element can be encapsulated into a Sys.UI.DomElement object in asp.net ajax. Then you can use its methods: addHandler(), addHandlers(), removeHander() to operate the event list. How convenient. I didn't quite understand this principle at the time. Today I saw the two pieces of code in the reference material below, which made me fully understand the details:
1. Use the interface in dom 2:
if(document.addEventListener){
window.addEventListener('load',f,false);
window.addEventListener('load',f1,false);
……
}else{
window.attachEvent('onload',f);
window.attachEvent('onload',f1);
......
}
It turns out that this concept has already existed in DOM. Only then did I know. It seems that there are still many things I don’t understand about dom.
2. This method is implemented purely by hand. Please see the code below:
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
This function is very cleverly written. Use anonymous functions to get it done!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

When developing websites using CraftCMS, you often encounter resource file caching problems, especially when you frequently update CSS and JavaScript files, old versions of files may still be cached by the browser, causing users to not see the latest changes in time. This problem not only affects the user experience, but also increases the difficulty of development and debugging. Recently, I encountered similar troubles in my project, and after some exploration, I found the plugin wiejeben/craft-laravel-mix, which perfectly solved my caching problem.

Apache server is a powerful web server software that acts as a bridge between browsers and website servers. 1. It handles HTTP requests and returns web page content based on requests; 2. Modular design allows extended functions, such as support for SSL encryption and dynamic web pages; 3. Configuration files (such as virtual host configurations) need to be carefully set to avoid security vulnerabilities, and optimize performance parameters, such as thread count and timeout time, in order to build high-performance and secure web applications.

Nginx performance monitoring and troubleshooting are mainly carried out through the following steps: 1. Use nginx-V to view version information, and enable the stub_status module to monitor the number of active connections, requests and cache hit rate; 2. Use top command to monitor system resource occupation, iostat and vmstat monitor disk I/O and memory usage respectively; 3. Use tcpdump to capture packets to analyze network traffic and troubleshoot network connection problems; 4. Properly configure the number of worker processes to avoid insufficient concurrent processing capabilities or excessive process context switching overhead; 5. Correctly configure Nginx cache to avoid improper cache size settings; 6. By analyzing Nginx logs, such as using awk and grep commands or ELK

HTML5 code consists of tags, elements and attributes: 1. The tag defines the content type and is surrounded by angle brackets, such as. 2. Elements are composed of start tags, contents and end tags, such as contents. 3. Attributes define key-value pairs in the start tag, enhance functions, such as. These are the basic units for building web structure.
