How to adjust the JS file to improve the page speed

in the JS file after the position shift can let other priority code loading, but in the implementation of the JS file is still relatively time-consuming, if more JS file, on the need for multiple "Get" request, extend the loading speed. Then we naturally is to minimize Get requests. There are two kinds of schemes:



three, execute the JS file

JS is a merger, with more, most of the website are external calls JS, and now call JS together is also very common.

JS file is placed in front of the code behind the delay after loading, so we can consider to put JS in front of the /body or more thick, so you can make script HTML before the perfect present, will not let users see a blank page, to improve the experience of.

Most Whether the JS >

with Internet users demand, plus mobile devices become more and more popular, and the website loading speed attracts more and more attention of webmaster. The website loading time is a major reason for the loss of customers, ordinary users will not have the patience to wait a long "loading, but this point directly affects the operation of the site.

website will put JS file on the head, but many browsers will use a single thread to do web page loading and JS script processing, also is when the execution engine meets the script code, the page behind the loading will have to wait until completion of the performance of JS. If the JS execution speed is slow, so the user can only wait, then the user is likely to turn off the page.

fileAlthough the

, a JS file position adjustment

Since the

IE8, Firefox3.5 and Chrome2 realized parallel download JS, this is quite good, automatically shortens the execution time of the JS, but will stop some other resources download. For example JS file picture code until after the completion of the execution of the JS will be loaded, this can cause the user to wait, how to do

two, with JS

in Shanghai Webmaster Platform page optimization recommendations, love Shanghai focused on checking the website loading time of this one, and for the first time, the use of byte long links, enable gzip compression, image compression, static content cache time, reasonable use of Cookies, combined with CSS and JS files gives optimization suggestions. These will not say, "here is how to set up the JS file to improve loading speed.

: the first with the JS file, such as 1.js, 2.js and 3.js with.

second: the use of third party tools, such as PHP in Minify.

Leave a Reply

Your email address will not be published. Required fields are marked *