Home arrow PHP arrow Page 5 - Speed up Web Page Loading Using Google Page Speed

Optimizing the Order of JavaScript and CSS - PHP

The easiest way to improve your website's conversions may have less to do with SEO and your content and more to do with how fast your pages load. Internet users have a short attention span, and won't wait for your pages to load when the next site is just a click away. Fortunately, you can fix your web page loading times with the help of Google Page Speed.

TABLE OF CONTENTS:
  1. Speed up Web Page Loading Using Google Page Speed
  2. Introduction to Google Page Speed
  3. Page Loading Improvement Case Study
  4. GZIP Compression for CSS Files
  5. Optimizing the Order of JavaScript and CSS
By: Codex-M
Rating: starstarstarstarstar / 6
February 01, 2010

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
  

Optimizing the order of JavaScript is simple. You will need to cluster all JavaScript together as one group if possible, and let them execute first, before loading the CSS. This will benefit from any parallel loading of scripts which have an effect on loading speed. For example, if before it was:

 

<?php

//javascript groups in the header placed here

?>

 

<link rel="stylesheet" href="http://www.php-developer.org/wp-content/themes/arras-theme.1.3.5/css/layouts/2c-r-fixed.css" type="text/css" />

 

<script type="text/javascript">

     jQuery(document).ready(function($) {

          $('.sf-menu').superfish({autoArrows: false, speed: 'fast'});

     });

</script>

You can improve the first step by placing JavaScript above the CSS and grouping it (combining it) with the rest of the JavaScript.

<?php

//javascript groups in the header placed here

?>

<script type="text/javascript">

     jQuery(document).ready(function($) {

          $('.sf-menu').superfish({autoArrows: false, speed: 'fast'});

     });

</script>



 
 
>>> More PHP Articles          >>> More By Codex-M
 

blog comments powered by Disqus
   

PHP ARTICLES

- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap

Dev Shed Tutorial Topics: