Creating a minimal Node.js module

I strongly believe in the minimalistic approach when creating examples. Here is one minimal module: module.exports = function() { return “Hello World”; }; Here is the main.js: var hello = require(“./hello.js”); var moduleExportsFunction = hello(); console.log(moduleExportsFunction); If you call node main.js, the output will be: Hello World So what you get after the require is…

Tagged

Escape from the CommonJS

Node.js uses CommonJS module loading. CommonJS module loading doesn’t work with the browsers. The reason is simple. JavaScript cannot load another JavaScript module from the disk. Two workarounds: One to run a program like Browserify. Browserify will look for calls to require(), resolve all dependencies, and gather the needed code into a single big file….

Tagged , ,

Browser Features

Ambient Light Events, Application Cache, HTML5 Audio Element support and formats (ogg, mp3, opus, wav, m4a), Battery API, Blob constructor, Canvas, Canvas text, Content Editable, Context menus, Cross-Origin Resource Sharing, Web Cryptography, Custom protocol handler, CustomEvent, Dart, DataView, Emoji, Event Listener, EXIF Orientation, Fullscreen API, GamePad API, Geolocation API, Hashchange event, Hidden Scrollbar, History API,…

Tagged ,