Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 2.54 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*
  2. I have a *lot* of issues with the way HTTPArchive detects JavaScript libraries,
  3. but this is a feeble attempt to at least improve its detection of YUI to include
  4. both YUI 3.x and YUI 2.x, while minimizing false positives.
  5.  
  6. I haven't touched the patterns for other libraries, but I think they're very
  7. broken as well. The jQuery pattern, for instance, assumes that any URL
  8. containing the string "jquery" is the jQuery JavaScript library, which means it
  9. will return false positives for plugins ("jquery-pluginname.js"), paths
  10. "/jquery/bogus-file.js", and a variety of other URLs.
  11.  
  12. This applies to the patterns for Dojo, Quantcast, Twitter, and ShareThis as
  13. well.
  14.  
  15. The original HTTPArchive JS lib detection code can be found at:
  16. http://code.google.com/p/httparchive/source/browse/trunk/interesting-images.js#331
  17. */
  18.  
  19. // Old code:
  20. $hCond = array();
  21. $hCond["jQuery"] = "rt.url like '%jquery%'";
  22. $hCond["YUI"] = "rt.url like '%/yui/%'";
  23. $hCond["Dojo"] = "rt.url like '%dojo%'";
  24. $hCond["Google Analytics"] = "(rt.url like '%/ga.js%' or rt.url like '%/urchin.js%')";
  25. $hCond["Quantcast"] = "rt.url like '%quant.js%'";
  26. $hCond["AddThis"] = "rt.url like '%addthis.com%'";
  27. $hCond["Facebook"] = "(rt.url like '%facebook.com/plugins/%' or rt.url like '%facebook.com/widgets/%' or rt.url like '%facebook.com/connect/%')";
  28. $hCond["Google +1"] = "rt.url like '%google.com/js/plusone.js%'";
  29. $hCond["Twitter"] = "rt.url like '%twitter%'";
  30. $hCond["ShareThis"] = "rt.url like '%sharethis%'";
  31.  
  32. // New code (better YUI detection):
  33. $hCond = array();
  34. $hCond["jQuery"] = "rt.url like '%jquery%'";
  35. $hCond["YUI"] = "(rt.url like '%/yui-min.js%' or rt.url like '%/yui.js%' or rt.url like '%/yui-debug.js%' or rt.url like '%/yui-base-min.js%' or rt.url like '%/yui-base.js%' or rt.url like '%/yui-core-min.js%' or rt.url like '%/yui-core.js%' or rt.url like '%/simpleyui.js%' or rt.url like '%/simpleyui-min.js%' or rt.url like '%/yahoo.js%' or rt.url like '%/yahoo-min.js%' or rt.url like '%/yahoo-debug.js%' or rt.url like '%/yahoo-dom-event.js%' or rt.url like '%/yuiloader-dom-event.js%')";
  36. $hCond["Dojo"] = "rt.url like '%dojo%'";
  37. $hCond["Google Analytics"] = "(rt.url like '%/ga.js%' or rt.url like '%/urchin.js%')";
  38. $hCond["Quantcast"] = "rt.url like '%quant.js%'";
  39. $hCond["AddThis"] = "rt.url like '%addthis.com%'";
  40. $hCond["Facebook"] = "(rt.url like '%facebook.com/plugins/%' or rt.url like '%facebook.com/widgets/%' or rt.url like '%facebook.com/connect/%')";
  41. $hCond["Google +1"] = "rt.url like '%google.com/js/plusone.js%'";
  42. $hCond["Twitter"] = "rt.url like '%twitter%'";
  43. $hCond["ShareThis"] = "rt.url like '%sharethis%'";