Pages

Tuesday, September 12, 2017

Why Does Google.Com Have A Javascript Variable Called LOL

If you look at the Google homepage, you’ll notice the following image tag:

  1. <img alt="Google" height="92" id="hplogo"

  2. src="/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"


  3. onload="window.lol&amp;&amp;lol()">


So when the image tag is loaded, JavaScript checks if 1) a function named `lol` exists, and 2) if so, it runs that function.
What does the function do? Well, it turns out that the function named `lol` will resize and/or relocate the logo image depending on the screen size. So basically it’s responsive web design.
And what does `lol` mean here?
Well, it’s just short for “logo On Load”

No comments:

Post a Comment