Question: ```
$('button').click(function(){ console.log('works'); });

```

This outputs 'works' when I click the required button. 

But if I pack the same code in a function and call it with parentheses attached to it(as you usually invoke a function), as in 

```
function worker(){ console.log('works'); }
$('button').click(worker());

```

*worker* gets fired without any click on *button*. But if I avoid the parentheses, as in 

```
function worker(){ console.log('works'); }
$('button').click(worker);

```

I'm getting the desired functionality. Why the *click* handler behaves this way?

Answer: 
I'm quite certain you're missing two points explained in the [NodeMCU flashing docs](http://nodemcu.readthedocs.io/en/master/en/flash/):

* esptool.py `write_flash` options
* flashing the correct Espressif init data

Assuming you've got a 4MB device such as ESP-12E / WeMos D1 mini / NodeMCU devkit v2 ([comparison](http://frightanic.com/iot/comparison-of-esp8266-nodemcu-development-boards/)) the [`write_flash` options](http://nodemcu.readthedocs.io/en/latest/en/flash/#esptoolpy) are `-fm dio -fs 32m`.

You're likely [upgrading from an older NodeMCU version](http://nodemcu.readthedocs.io/en/master/en/flash/#upgrading-firmware). Therefore, you need to flash `esp_init_data_default.bin` to the right memory address.

Hence, the full flash command should be something like that:

`esptool.py --port /dev/cu.wchusbserialfa130 write_flash -fm dio -fs 32m 0x00000 nodemcu-master-13-modules-2016-04-09-12-28-55-float.bin 0x3fc000 esp_init_data_default.bin`

**Update 2016-10-20**

Thanks to a fix in the firmware you won't have to provide the init data yourself anymore, the firmware does it automatically if necessary. Has been available in the `dev` branch for a few days and will also be on `master` in early December 2016.
Tried to get it running but no way for my "WeMos Mini D1" using this line 

`esptool.py --port /dev/ttyUSB0 write_flash -fm dio -fs 32m 0x00000 my-nodemcu.bin 0x3fc000 esp_init_data_default.bin --verify`

Answer is:

```
Wrote 454656 bytes at 0x0 in 39.2 seconds (92.9 kbit/s) 
WARNING: Unlikely to work as data goes beyond end of flash. Hint: Use --flash_size 
Writing 36864 @ 0x3fc000... 16384 (44 %)
A fatal error occurred: Write failure, status: 36'

```

The image from the cloud build has only 6 options, so its unlikeley that the image is too large.