PassMark Logo
Home » Forum

Announcement

Collapse
No announcement yet.

Minify and Conditional Load

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Minify and Conditional Load

    With the apparent use of load times for Google Search Results, I have spent time thinking through speeding up of our site.

    I minified the highlight.js code (pulling out comments and spaces) and reduced the size to 3,804 bytes and I off loaded the script (along with the general site images) to an alternate domain.

    Only 5% of our users use the zoom script, yet every user has to download the script. I would like to develop a conditional load script to encapsulate the call for the hightlight.js script and <body onload="highlight();">. The basics would be:

    if Query starts with ?zoom
    then
    load highlight.js
    call onload highlight
    end

    suggestions? I plan to contact a programmer I know for help in a few days if no one here has a suggestion.

    Colin

  • #2
    There are some good (free) tools out there to look at page load times with very detailed breakdowns. Search Google for, Web Page load times

    I wouldn't think it is worth the trouble to avoid the highlight script load. As after the 1st page the script should be cached and at 3.8KB it will be smaller that just about any of the images you have on the site. What is the URL for your site?

    Comment


    • #3
      4specs.com

      Just trying to play with all the variables on page speed and loading. The major Christmas project is to change the outbound tracking code and that is leading me to rethink all the javascript on the site.

      Comment


      • #4
        Your site is already fairly quick. The home page is fairly spartian, so it loads fast. Some of the deeper pages have 20 or more images on them. But even so they are well optimsed so the pages remain < 150KB in total. I don't think the user will notice the once off load of the script.

        Comment


        • #5
          Check out the Free Chrome extension, Speed Tracer
          http://code.google.com/webtoolkit/speedtracer/

          Comment


          • #6
            We ran about 5,000 loads of the highlight.js script a day.

            I minified the js file and cut it to about 3,800 bytes.

            I asked a php/javascript programer who has done some other work for me to work out the conditional loading script. He released the copyright to me and I offer the code with no restrictions to Wrensoft and others to use.

            Add this to the last line of the highlight.js script - this is all that is needed:

            highlight();

            If you want you can download my minified script with this addition:

            http://www.4specs.com/highlight.js

            Add this code to each page where you want the highlighting to occur. I put this below the Google Analytics on the bottom of each page - this may have to be on one line and I am not sure about any page breaks while cutting and pasting this:

            <script type="text/javascript">
            //<![CDATA[
            if (location.search&&location.search.indexOf('zoom')> 0)document.write(unescape("%3Cscript src='/highlight.js' type='text/javascript'%3E%3C/script%3E"));
            //]]>
            </script>

            This is set up for xhtml code. For html code you would use:

            <script type="text/javascript">
            if (location.search&&location.search.indexOf('zoom')> 0)document.write(unescape("%3Cscript src='/highlight.js' type='text/javascript'%3E%3C/script%3E"));
            </script>

            This cut the number of loads of this script per day from 5,000 to 250. 4,750 users a day downloaded the script and never used the Zoom search. While 4specs is a very fast site, I am working to get into the very fast site rating in Google Sitemaps and have made other changes to eliminate downloading another small js file by combining it into the same footer with the GA and highlight scripts.

            Have a prosperous 2010!

            Colin

            Comment

            Working...
            X