Cut Page Load time in OSCommerce 2.3 & OSC to CSS

Cut Initial Page Loading times approx. 35% in OSCommerce 2.3 and OSC to CSS by letting Google host Jquery.

Measured with Page Speed, a new, unmodified install of OSCommerce 2.3 on a typical DSL connection had initial page loading times of about 8.5 to 9.0 seconds.

By doing nothing more than replacing the references to the main Jquery Libraries with Google API references, 3.5 seconds were whacked off the initial page load time, resulting in 5 to 5.5 second initial page loads.

To replace the Jquery references in OSCommerce 2.3 open:
includes/template_top.php
replace:

<script type="text/javascript" src="ext/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="ext/jquery/ui/jquery-ui-1.8.6.min.js"></script>

with:

<script type="text/javascript" src="<?php echo (isset($_SERVER&#91;'HTTPS'&#93;) && (strtolower($_SERVER&#91;'HTTPS'&#93;) == 'on') ? 'https://' : 'http://') . 'ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'; ?>"></script>
<script type="text/javascript" src="<?php echo (isset($_SERVER&#91;'HTTPS'&#93;) && (strtolower($_SERVER&#91;'HTTPS'&#93;) == 'on') ? 'https://' : 'http://') . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js'; ?>"></script>

To replace the Jquery references in OSC to CSS open:
includes/application_top.php
The references are added like this:

// Define Stylesheet(s) to be used.
$stylesheet='
<script type="text/javascript" src=" '.(isset($_SERVER&#91;'HTTPS'&#93;) && (strtolower($_SERVER&#91;'HTTPS'&#93;) == 'on') ? 'https://' : 'http://') . 'ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src=" '.(isset($_SERVER&#91;'HTTPS'&#93;) && (strtolower($_SERVER&#91;'HTTPS'&#93;) == 'on') ? 'https://' : 'http://') . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js"></script>';

There are at least three reasons why this works:

  1. Google delivers the two files compressed. These are huge files. OSCommerce 2.3 delivers these files with a combined size of 270.8 kb, Google compresses them to 73.6kb. 270kb is larger than the total size of all the catalog files.
  2. Parallelism: Up to six files at a time can be requested from one server. But since two files are being requested from a second server, Google API, you can download 8 files concurrently.
  3. The visitor to your website might not even have to download them. If your visitor has been to another site anytime within the past year where these very popular files are used, they are probably already downloaded!

4 thoughts on “Cut Page Load time in OSCommerce 2.3 & OSC to CSS

  1. Where can i find the full text of the code as it appears that part of it is missing in your great tutorial.

    Thanks

  2. Sorry, but it seems as my cut and paste was not working as it should as i could see and copy was the following:
    <script type="text/javascript" src="<?php echo (isset($_SERVER['HTTPS']) && (strtolow
    <script type="text/javascript" src="<?php echo (isset($_SERVER['HTTPS']) && (strtolow

    I have tried it again and seems to be okay
    Thanks

Comments are closed.