..


Sponsored Links

Javascript slows down the loading of your site? Try asynchronous mode!

Article written by Max Bossi
Page 1 of 2

How many times have we heard that JavaScript is the most frequent cause of delays in loading a web page? many times, right? This, unfortunately, comes from the fact that many services used on websites and blogs are supplied from outside by the inclusion of a web page in Javascript code. For example think of services like statistics, banner exchange, social plugins, shoutbox, etc..

All of these elements, as a rule, are loaded into the web page through the use of <script> this:

 



 <script type="text/javascript" src="http://www.sitoesterno.com/servizio.js"> </ script>

 
This type of markup, as anticipated, suffers a significant problem: if the external resources does not respond quickly (eg because the server is overloaded or there is a temporary network problem) the browser, called to display the web page host this code, it will block waiting for loading the javascript is loaded. The consequence is that the web page could become very slow or, at worst, there may be white ... resulting in loss of traffic!

JavaScript can slow down your site!

Solve the problem easily

One solution to this problem is offered by the use of tags <iframe> but this is not always possible: when the element to be incorporated has a definite size (eg a banner) you can use this solution ... but when the element has to include different sizes or use the dynamic effects, the iframe is certainly inadequate.

A second solution, which is also very simple, is to place the JavaScript code that does not directly produce an output (such as statistics) at the bottom just before the close of <body> ... but when our code needs to produce an output and this has to be positioned at a precise point of our layout this is not, of course, possible.

Both of these simple solutions, therefore, are not the answer you're looking for ... We see, then, what is it and how the asynchronous loading of javascript code.

In the same category ...
E-Learning
CSS (Course) CSS (Course)
Web Design and Accessibility according to W3C CSS and XHTML. Starting from 29 €.
HTML (Course) HTML (Course)
The markup language for the Web from 29 €.
Javascript (Course) Javascript (Course)
Complete guide to client-side scripting. From 39 €.
Sponsored Links