1 / 6

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

CS193H: High Performance Web Sites Lecture 15: Rule 12 – Remove Duplicate Scripts. Steve Souders Google souders@cs.stanford.edu. Duplicate Scripts. hurts performance extra HTTP requests if not cacheable http://stevesouders.com/hpws/dupe-scripts.php IE and FF extra executions

hisoki
Télécharger la présentation

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

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. 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

  3. 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) . '"></script>"; } ?>

  4. 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

  5. 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

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

More Related