SlideShare a Scribd company logo
What is Mantri?
✓ Manages Web Application's Dependencies

✓ Leaves no footprint on production

✓ Offers a complete workflow

✓ IE6+

                                         #mantrijs
                                      mantrijs.com
What Dependencies?
● Multiple Javascript Files
● Each file can depend on other files
● Order of loading
● Order of evaluation
● Order of concatenating and building



                                           #mantrijs
                                        mantrijs.com
Why Manage?
● Automatic dependency resolution
● Enables large scale applications
● Collaboration between large teams
● Code scalability
● Better readability



                                         #mantrijs
                                      mantrijs.com
Mantri Development Cycle




                              #mantrijs
                           mantrijs.com
Page Load Breakout
Mantri Runtime
Starts Parsing

                                    mantriConf
                 Synchronous XHR
                                    .json


                  document.write    Vendor
                 ('<script>...');   Libs


                 Synchronous XHR    deps.js


                  document.write
                 ('<script>...');   Your
                                    Application

  Mantri Runtime Finishes
          Parsing




                                                     #mantrijs
                                                  mantrijs.com
Mantri 50k feet View
                                           $ mantri deps




          Resolves Deps ✓
  Concats app to one file ✓
Strips require statements ✓
            Compiles app ✓
     Optionally wraps app ✓
       Minifies third-party ✓
         Concatenates all ✓
                                $ mantri
                                build                         #mantrijs
                                                           mantrijs.com
Web Development with Mantri
The Natural Way




                     #mantrijs
                  mantrijs.com
Mantri Declarations
                         goog.provide('app');

                         goog.require('app.model.User');
                         goog.require('app.view.main');

                         var user = new app.model.User();




goog.provide('app.model.User');                   goog.provide('app.view.main');

goog.require('app.helpers');                      goog.require('app.view.front);
                                                  goog.require('app.view.about);
app.model.User = function() {                     goog.require('app.view.login);
  // ...




                                                                                #mantrijs
                                                                             mantrijs.com
Dependency Tree




                     #mantrijs
                  mantrijs.com
Mantri Uses Namespaces
goog.provide('app.views.frontpage');

// equals to
var app = app || {};
app.views = app.views || {};
app.views.frontpage = app.views.frontpage || {};

// and...
window.app === app;




                                                      #mantrijs
                                                   mantrijs.com
The HTML Document
<script src="js/libs/mantri.web.js"></script>




<script data-require="app" ...
<script data-config="/mantriConf.json" ...
<script data-deps="/deps.js" ...




                                                   #mantrijs
                                                mantrijs.com
Required Files
mantriConf.json              deps.js
● Declare third-party libs   ● Auto generated
● Dependency Config          ● Command line
● Build Config               ● Each time a declaration
                                changes




                                                     #mantrijs
                                                  mantrijs.com
Building Your Application
$ mantri build




✓ Grunt Task




                               #mantrijs
                            mantrijs.com
Workflow Concepts
Application Wrapping
"outputWrapper": "(function(){<%=output%>})();"




● IIFEs are cool
● "Hides" all previously global variables
● Explicit exposing




                                                     #mantrijs
                                                  mantrijs.com
Module Definitions
CommonJS                             AMD   Asynchronous Module Definition

●   Used in node.js                  ●   Extended browser support
●   Supported in Browser             ●   Uses function factories
●   Uses exports and module.         ●   Encapsulates each file in an
    exports keywords                     anon function


[[ harmony:modules ]]          ES6

●   Spec is not out yet
●   Doesn't support existing
    definitions (yet?)
●   Not a module loader




                                                                           #mantrijs
                                                                        mantrijs.com
Universal Module Definitions
  ...or how you can expose your library as a CommonJS or AMD module.

      UMD module definitions can work anywhere, be it in the client, on the
      server or anywhere else.


(function (root, factory) {
  if (typeof exports === 'object') {
    module.exports = factory();
  } else if (typeof define === 'function' && define.amd) {
    define(factory);
  } else {
    root.returnExports = factory();
  }
}(this, function(){return app;}));
                                                             https://github.com/umdjs/umd/
                                                                                  #mantrijs
                                                                               mantrijs.com
Using Namespaces
● Debugging from console
● Dead easy stubbing and mocking for testing
● Increases visibility and maintainability
● Scales smoothly
● Modern build flows decouple development from
   production




                                                    #mantrijs
                                                 mantrijs.com
So Why Not Modules?
● The Web is not the server. Nor it will ever be.
● Module Definitions are not Module Loaders.
● Debugging requires inspector with break points.
● Stubbing for Testing is really hard.
● Nasty problems, lengthy troubleshooting.
● Overhead. ~+7.5% minified, ~+5.5% gzip




                                                       #mantrijs
                                                    mantrijs.com
Why not Namespaces?
● Can become verbose app.ui.combo.EventType Use an alias
● Namespace conflicts        Use a wrapping IIFE

● Exposes internal methods Use a wrapping IIFE
● Modules are the future Use a wrapping IIFE, UMD
● Modules are cool




                                                              #mantrijs
                                                           mantrijs.com
Namespaces vs Modules
Tokens
●   requires build                goog.provide('app.views.main'');

●   large scale ready             goog.require('app.views.frontpage');
                                  /* win */
●   calculates once per build


Filenames
●   no build requirement          define('viewMain, ['app/views/frontpage'],
●   can't move files or folders     function (viewFrontpage) { /* .. */ });

    easily
●   calculates on each page
    load



                                                                            #mantrijs
                                                                         mantrijs.com
Recap, Mantri Features
Mantri Specifications
● Synchronous, app loads before DomContentLoaded
● No footprint on production
● Simple provide and require statements
● Available on NPM




                                                  #mantrijs
                                               mantrijs.com
Mantri Specifications
● Wraps around Google Closure Tools
● Uses Grunt Task Manager
● Abstracts the complexity away
● Low entry barrier that scales seamlessly




                                                #mantrijs
                                             mantrijs.com
Thank You!


http://mantrijs.com

#mantrijs
@thanpolas
http://thanpol.as

More Related Content

Viewers also liked

Intro to node.js web apps
Intro to node.js web appsIntro to node.js web apps
Intro to node.js web apps
Thanos Polychronakis
 
HowTo Freelance
HowTo FreelanceHowTo Freelance
HowTo Freelance
Thanos Polychronakis
 
Entities, the theory
Entities, the theoryEntities, the theory
Entities, the theory
Thanos Polychronakis
 
Entities on Node.JS
Entities on Node.JSEntities on Node.JS
Entities on Node.JS
Thanos Polychronakis
 
Intro to node.js
Intro to node.jsIntro to node.js
Intro to node.js
Thanos Polychronakis
 

Viewers also liked (6)

Intro to node.js web apps
Intro to node.js web appsIntro to node.js web apps
Intro to node.js web apps
 
HowTo Freelance
HowTo FreelanceHowTo Freelance
HowTo Freelance
 
Entities, the theory
Entities, the theoryEntities, the theory
Entities, the theory
 
Entities on Node.JS
Entities on Node.JSEntities on Node.JS
Entities on Node.JS
 
Metrics - Hands On
Metrics - Hands OnMetrics - Hands On
Metrics - Hands On
 
Intro to node.js
Intro to node.jsIntro to node.js
Intro to node.js
 

Similar to Mantri Presentation One

A Story about AngularJS modularization development
A Story about AngularJS modularization developmentA Story about AngularJS modularization development
A Story about AngularJS modularization development
Johannes Weber
 
Asynchronous Module Definition (AMD)
Asynchronous Module Definition (AMD)Asynchronous Module Definition (AMD)
Asynchronous Module Definition (AMD)
xMartin12
 
Java2day 2013 : Modern workflows for javascript integration
Java2day 2013 : Modern workflows for javascript integrationJava2day 2013 : Modern workflows for javascript integration
Java2day 2013 : Modern workflows for javascript integrationMite Mitreski
 
Story about module management with angular.js
Story about module management with angular.jsStory about module management with angular.js
Story about module management with angular.js
David Amend
 
JSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendJSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontend
Vlad Fedosov
 
Isomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master ClassIsomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master ClassSpike Brehm
 
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JSFestUA
 
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausHTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
Women in Technology Poland
 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalability
Twinbit
 
Micro frontend
Micro frontendMicro frontend
Micro frontend
Amr Abd El Latief
 
Node.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniquesNode.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniques
Manuel Eusebio de Paz Carmona
 
Single Page Applications – Know The Ecosystem system
Single Page Applications – Know The Ecosystem systemSingle Page Applications – Know The Ecosystem system
Single Page Applications – Know The Ecosystem system
Synerzip
 
(Js) Export your own WebGL Viewer
(Js) Export your own WebGL Viewer(Js) Export your own WebGL Viewer
(Js) Export your own WebGL Viewer
JooinK
 
Deep dive into Android async operations
Deep dive into Android async operationsDeep dive into Android async operations
Deep dive into Android async operations
Mateusz Grzechociński
 
Griffon for the Enterprise
Griffon for the EnterpriseGriffon for the Enterprise
Griffon for the Enterprise
James Williams
 
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
Alessandro Molina
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
David Amend
 

Similar to Mantri Presentation One (20)

A Story about AngularJS modularization development
A Story about AngularJS modularization developmentA Story about AngularJS modularization development
A Story about AngularJS modularization development
 
Asynchronous Module Definition (AMD)
Asynchronous Module Definition (AMD)Asynchronous Module Definition (AMD)
Asynchronous Module Definition (AMD)
 
Java2day 2013 : Modern workflows for javascript integration
Java2day 2013 : Modern workflows for javascript integrationJava2day 2013 : Modern workflows for javascript integration
Java2day 2013 : Modern workflows for javascript integration
 
Story about module management with angular.js
Story about module management with angular.jsStory about module management with angular.js
Story about module management with angular.js
 
JSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontendJSFest 2019: Technology agnostic microservices at SPA frontend
JSFest 2019: Technology agnostic microservices at SPA frontend
 
Isomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master ClassIsomorphic JavaScript: #DevBeat Master Class
Isomorphic JavaScript: #DevBeat Master Class
 
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
JS Fest 2019/Autumn. Влад Федосов. Technology agnostic microservices at SPA f...
 
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausHTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
 
Grails 101
Grails 101Grails 101
Grails 101
 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalability
 
Micro frontend
Micro frontendMicro frontend
Micro frontend
 
Hello android
Hello androidHello android
Hello android
 
Node.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniquesNode.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniques
 
Single Page Applications – Know The Ecosystem system
Single Page Applications – Know The Ecosystem systemSingle Page Applications – Know The Ecosystem system
Single Page Applications – Know The Ecosystem system
 
(Js) Export your own WebGL Viewer
(Js) Export your own WebGL Viewer(Js) Export your own WebGL Viewer
(Js) Export your own WebGL Viewer
 
Deep dive into Android async operations
Deep dive into Android async operationsDeep dive into Android async operations
Deep dive into Android async operations
 
Griffon for the Enterprise
Griffon for the EnterpriseGriffon for the Enterprise
Griffon for the Enterprise
 
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
 
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
 

Recently uploaded

みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 

Recently uploaded (20)

みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 

Mantri Presentation One

  • 1.
  • 2. What is Mantri? ✓ Manages Web Application's Dependencies ✓ Leaves no footprint on production ✓ Offers a complete workflow ✓ IE6+ #mantrijs mantrijs.com
  • 3. What Dependencies? ● Multiple Javascript Files ● Each file can depend on other files ● Order of loading ● Order of evaluation ● Order of concatenating and building #mantrijs mantrijs.com
  • 4. Why Manage? ● Automatic dependency resolution ● Enables large scale applications ● Collaboration between large teams ● Code scalability ● Better readability #mantrijs mantrijs.com
  • 5. Mantri Development Cycle #mantrijs mantrijs.com
  • 6. Page Load Breakout Mantri Runtime Starts Parsing mantriConf Synchronous XHR .json document.write Vendor ('<script>...'); Libs Synchronous XHR deps.js document.write ('<script>...'); Your Application Mantri Runtime Finishes Parsing #mantrijs mantrijs.com
  • 7. Mantri 50k feet View $ mantri deps Resolves Deps ✓ Concats app to one file ✓ Strips require statements ✓ Compiles app ✓ Optionally wraps app ✓ Minifies third-party ✓ Concatenates all ✓ $ mantri build #mantrijs mantrijs.com
  • 9. The Natural Way #mantrijs mantrijs.com
  • 10. Mantri Declarations goog.provide('app'); goog.require('app.model.User'); goog.require('app.view.main'); var user = new app.model.User(); goog.provide('app.model.User'); goog.provide('app.view.main'); goog.require('app.helpers'); goog.require('app.view.front); goog.require('app.view.about); app.model.User = function() { goog.require('app.view.login); // ... #mantrijs mantrijs.com
  • 11. Dependency Tree #mantrijs mantrijs.com
  • 12. Mantri Uses Namespaces goog.provide('app.views.frontpage'); // equals to var app = app || {}; app.views = app.views || {}; app.views.frontpage = app.views.frontpage || {}; // and... window.app === app; #mantrijs mantrijs.com
  • 13. The HTML Document <script src="js/libs/mantri.web.js"></script> <script data-require="app" ... <script data-config="/mantriConf.json" ... <script data-deps="/deps.js" ... #mantrijs mantrijs.com
  • 14. Required Files mantriConf.json deps.js ● Declare third-party libs ● Auto generated ● Dependency Config ● Command line ● Build Config ● Each time a declaration changes #mantrijs mantrijs.com
  • 15. Building Your Application $ mantri build ✓ Grunt Task #mantrijs mantrijs.com
  • 17. Application Wrapping "outputWrapper": "(function(){<%=output%>})();" ● IIFEs are cool ● "Hides" all previously global variables ● Explicit exposing #mantrijs mantrijs.com
  • 18. Module Definitions CommonJS AMD Asynchronous Module Definition ● Used in node.js ● Extended browser support ● Supported in Browser ● Uses function factories ● Uses exports and module. ● Encapsulates each file in an exports keywords anon function [[ harmony:modules ]] ES6 ● Spec is not out yet ● Doesn't support existing definitions (yet?) ● Not a module loader #mantrijs mantrijs.com
  • 19. Universal Module Definitions ...or how you can expose your library as a CommonJS or AMD module. UMD module definitions can work anywhere, be it in the client, on the server or anywhere else. (function (root, factory) { if (typeof exports === 'object') { module.exports = factory(); } else if (typeof define === 'function' && define.amd) { define(factory); } else { root.returnExports = factory(); } }(this, function(){return app;})); https://github.com/umdjs/umd/ #mantrijs mantrijs.com
  • 20. Using Namespaces ● Debugging from console ● Dead easy stubbing and mocking for testing ● Increases visibility and maintainability ● Scales smoothly ● Modern build flows decouple development from production #mantrijs mantrijs.com
  • 21. So Why Not Modules? ● The Web is not the server. Nor it will ever be. ● Module Definitions are not Module Loaders. ● Debugging requires inspector with break points. ● Stubbing for Testing is really hard. ● Nasty problems, lengthy troubleshooting. ● Overhead. ~+7.5% minified, ~+5.5% gzip #mantrijs mantrijs.com
  • 22. Why not Namespaces? ● Can become verbose app.ui.combo.EventType Use an alias ● Namespace conflicts Use a wrapping IIFE ● Exposes internal methods Use a wrapping IIFE ● Modules are the future Use a wrapping IIFE, UMD ● Modules are cool #mantrijs mantrijs.com
  • 23. Namespaces vs Modules Tokens ● requires build goog.provide('app.views.main''); ● large scale ready goog.require('app.views.frontpage'); /* win */ ● calculates once per build Filenames ● no build requirement define('viewMain, ['app/views/frontpage'], ● can't move files or folders function (viewFrontpage) { /* .. */ }); easily ● calculates on each page load #mantrijs mantrijs.com
  • 25. Mantri Specifications ● Synchronous, app loads before DomContentLoaded ● No footprint on production ● Simple provide and require statements ● Available on NPM #mantrijs mantrijs.com
  • 26. Mantri Specifications ● Wraps around Google Closure Tools ● Uses Grunt Task Manager ● Abstracts the complexity away ● Low entry barrier that scales seamlessly #mantrijs mantrijs.com