Trying out head.js - after


/ Published in: JavaScript
Save to your folder(s)

Trying out head.js - available at http://headjs.com/


Copy this code and paste it in your HTML
  1. // load scripts by assigning a label for them
  2. head.js(
  3. {jquery: "http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"},
  4. {custom: "<?php echo get_bloginfo(template_url); ?>/include/js/main.js"}
  5. );
  6.  
  7. //call this function as soon as jquery is ready
  8. head.ready("jquery", function(){
  9. //fade in the background
  10. jQuery('#pageBackground').fadeIn('1500');
  11. jQuery('section').delay('900').fadeIn('1500');
  12.  
  13. //resize background script from example at http://css-tricks.com/perfect-full-page-background-image/
  14. var theWindow = $(window),
  15. $bg = $("#pageBackground"),
  16. aspectRatio = $bg.width() / $bg.height();
  17. function resizeBg() {
  18. if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
  19. $bg
  20. .removeClass()
  21. .addClass('bgheight');
  22. } else {
  23. $bg
  24. .removeClass()
  25. .addClass('bgwidth');
  26. }
  27. }
  28. theWindow.resize(function() {
  29. resizeBg();
  30. }).trigger("resize");
  31. });
  32.  
  33. //google stats
  34. head.js("http://www.google-analytics.com/ga.js", function() {
  35. var tracker = _gat._getTracker("UA-XXXXXX-X");
  36. tracker._trackPageview();
  37. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.