Your location:Tech News>News>Script>Several ways to delay loading JS code to speed up web page access speed

Latest News

Several ways to delay loading JS code to speed up web page access speed

Author:fsadmin

Views:

  This article describes how to delay loading of javascript code to speed up the access speed of the page.

  When a site has a lot of code to load js, js code is placed in a position to some extent, the image will load faster web page, in order to make our pages load faster, the paper summed up several attention points:

  1, delay loading js code

  Copy the code code is as follows:

  

  

  So lazily js code to the page loads allow more time!

  2, js last load a program

  Where you need to insert the JS insert the following code:

  code

  Copy the code code is as follows:

  LOADING .

  Of course, that LOADING . you can replace your favorite small picture.AJAX effect it looks very.

  In the bottom of the page then insert:

  code

  Copy the code code is as follows:

  Your JS code here!

  

  3, let JS loaded last program two

  This involves loading order Pages, for example, the introduction of external js script file, if placed in the head html, js the pages of the script will be loaded before the page is loaded, and into the body, the page will follow from on the fallen loading order to run javascript code ~ ~ ~ so we can file an external js introduced into the bottom of the page, to make the final js introduced to speed up page loading speed.

  You may also be interested in the article: js methods and differences in sync with the asynchronous processing summary synchronous load and asynchronous javascript file is loaded realization of the principle Javascript implementation commodity spike countdown (time synchronization with the server time) three js loaded asynchronously solution of jquery receiving a request to return json ajax asynchronous data instances jQuery Ajax json asynchronous data processing delay loading Explanation JS (setTimeout) JS js function setTimeout loaded last executed brief delay Jquery.LazyLoad.js revised version download, realize picture delay (three ways) JS synchronous, asynchronous, lazy loading method to load the plug-JS jump page is delayed by two kinds of methods to realize pictures javascript lazy loading method summary

Recommend article

Relate article