Wednesday, November 6, 2013

make javascript Speed Up (1)

Do you Think which sample is better between two samples

1. <html>
    <head>
         <script type ="text/javascript" src="file1.js"></script>
         <script type ="text/javascript" src="file2.js"></script>
         <script type ="text/javascript" src="file3.js"></script>
   </head>
<body>
...
</body>
<html>



2. <html>
    <head>
   </head>
<body>
...
//end of body
         <script type ="text/javascript" src="file1.js"></script>
         <script type ="text/javascript" src="file2.js"></script>
         <script type ="text/javascript" src="file3.js"></script>
</body>
<html> 



First is well-known pattern when we use javascript, and also we learn like 1 sample

but until scripts are fully loaded we will see white page


Second sample is better than first
because after body is loaded javascript will run

No comments:

Post a Comment