By Oleksii Rudenko October 1, 2015 10:00 PM
Best Web Development Answers on StackOverflow - September, 2015

We selected 4 best answers of September on Stack Overflow that are related to Web Development.

Should I inline all CSS files programmatically to optimize page load speed?

Asked by Shaun Luttin. The best answer (56 votes) supports our understanding that generally inlining is bad for the web page performance because it disables browser caching of the styles:

Inlining all your CSS means it cannot be cached, so every single page load will contain all of the CSS required, and when you are using large libraries that can really be a lot of wasted bandwidth. For example, Bootstrap is around 120k. Note the Google link you shared specifies the following (emphasis mine):

says [DavidG](

However, for small CSS files it may make sense to inline them in html. But because amount of styles tends to grow inlining should really be the last resort.

The topic starter wanted to inline styles in order to reduce the number of network round trips. It’s worth mentioning that with the advancement of HTTP/2 the number of round trips will become less and less of an issue. So in the long-term serving your styles in a separate file is more beneficial.

Javascript return with colon?

Sean who is just learning Javascript encountered the following code structure:

var Test = (function () {

  function func1() {
      //do something.....

  function func2() {
      //do something.....

  function func3() {
      //do something.....

  return {
      func1: func1,
      func2: func2,
      func3: func3


As the best answer(42 votes) points out, it’s a Revealing Module Pattern:

The main idea behind the pattern is avoiding evil global variables. This looks similar to IIFE except an object is returned instead of function. The variables/methods defined inside the IIFE are private to the function. To access any variable/method inside the IIFE, it needs to be added in the returned object and then it can be accessed from outside of IIFE. This pattern takes advantage of closures, so the variables/methods defined inside the IIFE are accessible even after the object is returned.

says [Tushar](

Thus, what’s returned by the IIFE is what the module exposes to the outside. Other stuff inside the IIFE is private.

We hope that ES6 modules will soon be prevailing so one will not have to build structures like in the question. An ES6 equivalent for this is:


export function func1() {
    //do something.....

export function func2() {
    //do something.....

export function func3() {
    //do something.....

Getting NaN inconsistently mapping parseInt

ReferentiallySeethru came up with the following code:

var arr = new Array(32).join(0).split('').map(parseInt)
// prints [0, NaN, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

That prints NaN without noticeable reasons. The best answer(26 votes) explains:

That's because the function passed to map will be called with three arguments:

1. The current array item <br>
2. The index of that item <br>
3. The whole array<br>

In this case, that function is parseInt, which only uses two arguments:

1. The string to be parsed<br>
2. The radix used to parse the string<br>
3. Additional arguments will be ignored.<br>

Therefore, for the 2nd item in the array (i.e. index 1), the call will be

  parseInt("0", 1, ignoredArray)
```. When the radix is 1, NaN is returned.

says [Oriol](

Well, let’s just check the API docs before raising a question :-) Nevertheless, the answer is full of insights about how the parseInt function works.

Two in one object declaration

What should happen? - asks Randomblue:

var o = {,};

Will o.a === o.b?

The answer is No (21 votes). Well, it’s not just No. The answer refers to the corresponding specification:

When we look at the spec for (, it simply says that it returns

the time value designating the UTC date and time of the occurrence of the call to now

which provides no guarantees to two calls ever returning the same value. From what I can tell, the spec specifies that Date objects will have millisecond precision ( but makes no guarantees as to accuracy.
It is likely that two calls in the same line will probably return the same time, by virtue of the underlying timer being imprecise and the two occurring within the same tick, but the spec does not appear to specify that.

says [ssube](

The next answer actually provides a way to test how often two dates will be equal:

var test = new Array();
for(var i=0; i<40000; i++){
for(var i=0 ; i<test.length; i++){
  if(test[i].a != test[i].b){
     console.warn('a & b !=');

On my machine, it’s approximately 10 / 40000. So let’s not rely on this :-)

We hope we all learned something new from these answers. Thanks for reading and till the next time!