develop plugin for mozilla firefox and structure a js-based application

19
Develop plugin for Mozilla Firefox and structure a JavaScript-based application

Upload: afshin-mehrabani

Post on 01-Dec-2014

727 views

Category:

Software


4 download

DESCRIPTION

How to develop a plugin for Mozilla Firefox and structure a JS-based application using AMD, CommonJS and Harmony.

TRANSCRIPT

Page 1: Develop plugin for Mozilla Firefox and structure a JS-based application

Develop plugin for Mozilla Firefoxand structure a JavaScript-based application

Page 2: Develop plugin for Mozilla Firefox and structure a JS-based application

Modular JavaScript

Page 3: Develop plugin for Mozilla Firefox and structure a JS-based application

• CommonJS

• AMD

• Harmony (ECMAScript.next)

Page 4: Develop plugin for Mozilla Firefox and structure a JS-based application

CommonJSA Module Format Optimized For The Server

Page 5: Develop plugin for Mozilla Firefox and structure a JS-based application

// package/lib is a dependency we require var lib = require('package/lib'); // some behavior for our module function foo(){ lib.log('hello world!'); } // export (expose) foo to other modules exports.foo = foo;

Page 6: Develop plugin for Mozilla Firefox and structure a JS-based application

AMDAsynchronous Module Definition

Page 7: Develop plugin for Mozilla Firefox and structure a JS-based application

“CommonJS AMD format”

Page 8: Develop plugin for Mozilla Firefox and structure a JS-based application

Proposal for defining modules where both the module and dependencies can be asynchronously loaded.

Page 9: Develop plugin for Mozilla Firefox and structure a JS-based application
Page 10: Develop plugin for Mozilla Firefox and structure a JS-based application

define( module_id, [dependencies], definition function );

Page 11: Develop plugin for Mozilla Firefox and structure a JS-based application

AMD & CommonJSA module that works in both server-side and client-side

Page 12: Develop plugin for Mozilla Firefox and structure a JS-based application

UMDjshttps://github.com/umdjs/umd

Page 13: Develop plugin for Mozilla Firefox and structure a JS-based application

Develop for Firefox

Page 14: Develop plugin for Mozilla Firefox and structure a JS-based application

ClassicTraditional, classic, or XUL extensions

Page 15: Develop plugin for Mozilla Firefox and structure a JS-based application

<menu id="xulschoolhello-hello-menu" label="&xulschoolhello.hello.label;" accesskey="&xulschoolhello.helloMenu.accesskey;" insertafter="helpMenu"> <menupopup> <menuitem id="xulschoolhello-hello-menu-item" label="&xulschoolhello.hello.label;" accesskey="&xulschoolhello.helloItem.accesskey;" oncommand="XULSchoolChrome.BrowserOverlay.sayHello(event);" /> </menupopup> </menu>

Page 16: Develop plugin for Mozilla Firefox and structure a JS-based application

Add-on SDKHTML, CSS, JavaScript

Page 17: Develop plugin for Mozilla Firefox and structure a JS-based application

Using the Add-on SDK you can create Firefox add-ons using standard Web technologies: JavaScript, HTML, and CSS.

!The SDK includes JavaScript APIs which you can use to

create add-ons, and tools for creating, running, testing, and packaging add-ons.

Page 18: Develop plugin for Mozilla Firefox and structure a JS-based application

Sources

• Writing Modular JavaScript With AMD, CommonJS & ES Harmony written by Addy Osmani

• Mozilla developers network - developer.mozilla.org

Page 19: Develop plugin for Mozilla Firefox and structure a JS-based application

Afshin Mehrabani@afshinmeh

Thanks. Questions?