title: YYCjs Slides output: index.html theme: theme controls: false logo: theme/logo.png
-- title
-- title
-- presenter
-- presenter
-- sponsors
--
- Un-spaghetti and modularize your code
- Advanced selectors and DOM traversal
- Making your code faster
- Writing your own plugins
- Introduction to web components and Polymer
- Data driven views (or why direct DOM manipulation will be a thing of the past)
- Build web component style applications now with CanJS
--
Node.js is a platform built on Chrome's V8 JavaScript runtime for easily building fast, scalable network applications.
- HTTP/HTTPS
- TCP/UDP Sockets
- Event Emitters
- Streams
- Files System Access
- Cross Platform
-- image
It uses JavaScript and it has a single threaded event loop. There is a seperate thread pool for IO requests. (Image credited to Elegant Code)
--
- currently hosts ~63,000 modules
- easy to use (
npm install <package>
) - easy to publish (
npm publish
) - use it with anything (folders, tarballs, git repositories)
- Attempt for JavaScript API standardization
--
Provides global module
, exports
and require()
to define this files API
// module1.js
exports.hello = 'World';
// or
module.exports = {
hello: 'World'
}
Using the module
// main.js
var mod1 = require('./module1');
console.log(mod1.hello); // -> World
--
CommonJS specification for describing JavaScript packages
{
"name": "node-up",
"version": "0.1.0",
"author": "YYCJS <[email protected]>",
"description": "Server side JavaScript FTW!",
"scripts": {
"test": "mocha test",
"start": "node lib/main.js"
},
"main": "./lib/main.js",
"repository": {
"type": "git",
"url": "https://github.com/yycjs/node-up"
},
"dependencies": {
"somePackage": "> 1.0.0"
},
"devDependencies": {
"some-dev-only-package": "*"
},
"license": "MIT"
}
--
Create `example.js` like this:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
And run it like:
% node example.js
Server running at http://127.0.0.1:1337/
--
var http = require("http");
var url = require("url");
var path = require("path");
var fs = require("fs");
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname;
var filename = path.join(process.cwd(), 'assets', uri);
fs.readFile(filename, "binary", function(error, file) {
if (error) {
response.writeHead(500, {"Content-Type": "text/plain"});
response.write(error + "\n");
return response.end();
}
response.writeHead(200);
response.write(file, "binary");
response.end();
});
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
-- image
A sinatra inspired, web application framework. Its sort of the defacto.
-- image
Bringing websockety goodness to your nodejs app. Has fallback to older technologies.
-- image
A minimal, real-time, data-driven, wrapper over top of Express that leverages the evented nature of nodejs.
--
- Optimizing your JS workflow
- Modules revisited
- AMD + RequireJS
- Component
- Browserify
- Grunt
- Gulp