Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8365097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:34:48+00:00 2026-06-09T12:34:48+00:00

In JavaScript, we can get a number representing the current date/time like so: var

  • 0

In JavaScript, we can get a number representing the current date/time like so:

var dt = new Date();
var e = dt.getTime();

A slightly shorter hand way of doing this might be:

var f = (new Date()).getTime();

The most compact way of doing this is reflected in the following code:

var g = +new Date;  //11 bytes shorter

(See them working here: http://jsfiddle.net/es4XW/2/)

Now, when you search through the source code of the Google’s front page, you will find the second convention used 11 times. Therefore, it appears that on each occasion Google could save 11 bytes – 121 bytes in total.

Compression and caching will play a part in mitigating this, but surely it would be worthwhile for Google to make this simple switch.

Compare and contrast this with Amazon’s front page code, who do use the third convention (though not on every occasion).

So why aren’t Google interested in this optimization? Although 121 bytes is peanuts to most of us, I would have thought they would have been interested in squeezing every last bit of performance out of their front page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:34:49+00:00Added an answer on June 9, 2026 at 12:34 pm

    I’d say readability and thus maintainability over marginal byte savings.
    Also, the first 2 options are future proof, whereas the third option is an implementation detail which might get changed or works differently across engines (e.g. Rhino, Node).

    A 4th possibility to your examples would be to wrap the call into a function:

    var now = function() {
        return (new Date().getTime());
    }
    

    Of course this only saves a few bytes once you call it at least a few times.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im new at javascript and i can get this slider to work but not
I'm new to Javascript and for some reason I can't get the following code
In Javascript, for example, you can get the arity (the number of arguments a
I'm trying to make a drop down menu using javascript/jquery but can't get my
I am trying to write DOM viewer on JavaScript. How I can get all
How can I get a handle on my user control in JavaScript? <body> <form
How can I get all the function arguments in javascript inside an array? function(a,
How can I get the title of an HTML page with JavaScript?
I was reading How can I get query string values in JavaScript? on Stackoverflow
This could be a very basic Javascript I know but I just can't get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.