PreLoader wont run on Page Refresh

PreLoader wont run on Page Refresh

Hi all,

I have implemented a preloader for my site, it uses GSAP and a timeout function to ensure that the animation runs, even if the page has loaded (quickly).

However, upon uploading to the server (www.ainsleyclark.com), I have encountered that the preloader doesn't run on page refresh, I can only assume that this has something to do with the set timeout function but cant figure it out.

Many thanks in advance. 

  1.     /*
  2.         PreLoader
  3.     */
  4.     $("#preloader svg").removeClass("hidden");
  5.     $("#preloader h1").removeClass("hidden");

  6.     $(window).on('load', function() {

  7.         //Header Animation
  8.         TweenLite.from("#preloader h1", 0.6, {
  9.             y: -40,
  10.             opacity: 0,
  11.             ease: Sine.easeIn
  12.         })

  13.         //PreLoader Logo Animation
  14.         var preLoaderTL = new TimelineMax({
  15.             repeat: 2,
  16.             yoyo: true,
  17.             repeatDelay: 1
  18.         });

  19.         preLoaderTL
  20.             .to("#left_logo", 0.6, {
  21.                 strokeDashoffset: 0,
  22.                 ease: Sine.easeIn
  23.             })
  24.             .to("#slash", 0.6, {
  25.                 strokeDashoffset: 0,
  26.                 ease: Sine.easeIn
  27.             }, "-=0.4")
  28.             .to("#right_logo", 0.6, {
  29.                 strokeDashoffset: 0,
  30.                 ease: Sine.easeIn
  31.             }, "-=0.4")

  32.         //Sets a timeout for the preloader so it doesnt load too early.
  33.         setTimeout(function() {
  34.             $('#about, #skills, #contact').show();
  35.             TweenLite.to("#preloader h1", 0.6, {
  36.                 y: 40,
  37.                 opacity: 0,
  38.                 ease: Sine.easeIn
  39.             });
  40.             $("#preloader").fadeOut('slow', function() {
  41.                 drawLogoTL.play();
  42.                 homeBannerTL.play();
  43.             });
  44.         }, 3000);
  45.     });