JS solves cross domain and performance optimization, etc. __js

Source: Internet
Author: User

Cross-domain:

1. JSONP (Jsonp is the principle of dynamically inserting script tags) 2. Document.domain + iframe 3. Window.name, Window.postmessage 4. Set Agent page on server

Performance optimization:

1. Reduce the number of HTTP requests: CSS sprites, JS, CSS source code compression, picture size control appropriate; web Gzip,cdn hosting, data caching, Image server 2. The front-end template JS + data, reduce the bandwidth wasted due to HTML tags, the front-end with variables to save the AJAX request results, each operation of local variables, no request, reduce the number of requests 3. Use InnerHTML instead of DOM operations to reduce DOM operations and optimize JavaScript performance 4. Set ClassName instead of directly manipulating style 5 when you need to set a lot of styles. Less global variables, cached DOM node lookup results. Reduced IO read Operation 6. Avoid using CSS Expression (CSS expressions), also known as dynamic Properties 7. Picture preload, put the style sheet at the top, put the script at the bottom, plus the timestamp

HTTP status codes have those. What does the distinction mean?

1.100-199 is used to specify some action 2 that the client should correspond to. 200-299 is used to indicate that the request succeeded 3. 300-399 is used for files that have been moved and is often included in the locator header information to specify the new address information 4. 400-499 is used to indicate client error 400: Semantics is incorrect, the current request cannot be understood by the server 401: The current request requires user authentication 403: The server has understood the request, but refused to execute it 5. 500-599 is used to support server error 503: Service not available to get a string of Unicode encoding var dectohex = function (str) {
var res=[];
for (Var i=0;i < str.length;i++)
res[i]= ("+str.charcodeat" (i). toString). Slice (-4);
Return "\\u" +res.join ("\\u");
}
var hextodec = function (str) {
Str=str.replace (/\\/g, "%");
return unescape (str);
}
var str=dectohex ("Dectohex Unicode Encoding Conversion");
Console.log ("Encoded after:" +str+ "\ n \ nthe decoding:" +hextodec (str));



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.