Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS193H: High Performance Web Sites Lecture 15: Rule 12 – Remove Duplicate Scripts Steve Souders Google

Similar presentations


Presentation on theme: "CS193H: High Performance Web Sites Lecture 15: Rule 12 – Remove Duplicate Scripts Steve Souders Google"— Presentation transcript:

1 CS193H: High Performance Web Sites Lecture 15: Rule 12 – Remove Duplicate Scripts Steve Souders Google souders@cs.stanford.edu

2 announcements

3 Duplicate Scripts hurts performance extra HTTP requests if not cacheable http://stevesouders.com/hpws/dupe-scripts.php IE and FF extra executions http://stevesouders.com/hpws/dupe-scripts-cached10.php all browsers atypical? happens with ads http://www.aol.com/ adsonar.js (6K) loaded six times happens with iframes http://www.ossamples.com/recipes/ fc-os-ext.js (15K), gadgets_en.js (155K) each loaded 3 times

4 Script Insertion Functions <?php function insertScript($jsfile) { if ( alreadyInserted($jsfile) ) { return; } pushInserted($jsfile); if ( hasDependencies($jsfile) ) { $dependencies = getDependencies($jsfile); for ( $i = 0; $i < count($dependencies); $i++ ) { insertScript($dependencies[$i]); } echo '<script type="text/javascript" src="'. getVersion($jsfile). '"> "; } ?>

5 Web 100 Profile project Aravind and I added 4 columns to compare double checks: delta YSlow = YSlow1 – YSlow2 delta %age time = ( (backend1/total1) – (backend2/total2) ) delta # requests % = ( (requests1 – requests2)/requests1 ) delta total size % = ( (size1 – size2)/size1 ) goals: <10 & <20% & <10% & <20% ~half of the sites had deltas bigger than this

6 Homework 11/7 11:59pm – rules 4-10 applied to your "Improving a Top Site" class project 11/12 3:15pm – Web 100 Double Check look at your rows in Web 100 spreadsheet double-check your entries for any rows in red update incorrect entries enter "y" in "Double Checked" column

7 Questions What are two typical causes of duplicate scripts? In what way(s) can duplicate scripts be bad for performance?


Download ppt "CS193H: High Performance Web Sites Lecture 15: Rule 12 – Remove Duplicate Scripts Steve Souders Google"

Similar presentations


Ads by Google