SlideShare ist ein Scribd-Unternehmen logo
1 von 36
Downloaden Sie, um offline zu lesen
PyJs
                           demixcn@gmail.com




Monday, September 19, 11
A CommonJS Based
                           Javascript Framework
                              runs on Browser

                               https://github.com/demix/pyjs




Monday, September 19, 11
CommonJS


Monday, September 19, 11
Math.js




                           increment.js




                           program.js(main)




Monday, September 19, 11
Benifits


Monday, September 19, 11
One code , runs everywhere

                           No need to study and follow an ugly module
                           pattern

                           Automatic namespace




Monday, September 19, 11
Browser

                           Server

                           Desktop

                           Command line tools

                           ...




Monday, September 19, 11
One code , runs everywhere

                           No need to study and follow an ugly module
                           pattern

                           Automatic namespace




Monday, September 19, 11
Traditional Module Pattern




                           CommonJS Module




Monday, September 19, 11
One code , runs everywhere

                           No need to study and follow an ugly module
                           pattern

                           Automatic namespace




Monday, September 19, 11
Monday, September 19, 11
Examples
                           Server side Example:

                             NodeJS

                           Browser side Example:

                             Firefox jetpack
                             project




Monday, September 19, 11
Problem


Monday, September 19, 11
Run directly after ‘require’.
                                 No Callback.




Monday, September 19, 11
Means in Browser, we can only use

                                    “Synchronous”

                              request to get the script file.




Monday, September 19, 11
What’s the fxxk...




Monday, September 19, 11
SeaJS


Monday, September 19, 11
Monday, September 19, 11
How it works


                           User pre-defined template wrapper.



                           Prefetch Js file which has been required.




Monday, September 19, 11
Problems


                           Still ugly template.



                           Still can’t download all files in parallel




Monday, September 19, 11
PyJS


Monday, September 19, 11
Grammar




Monday, September 19, 11
99% same as CommonJS API

                           No ugly user pre-defined template wrapper




Monday, September 19, 11
what about the file
                            loading problem?
                               You haven’t
                              mentioned it ..




Monday, September 19, 11
There is two loading rules in PyJS.

                                One in local debugging,

                              the other in online building.

                            All need Python environment.




Monday, September 19, 11
Local debugging

                           python pyjs.py runserver



                           Fetch the JS file in synchronous XHR request.



                           Server will parse the module file automaticly



Monday, September 19, 11
Server parse




Monday, September 19, 11
Online building
                           python pyjs.py

                           Automaticly generate a ‘boot.js’ file, find all the
                           dependences in modules and add the
                           information to the end of boot.js file.




Monday, September 19, 11
Then , if we had a combo service like:




Monday, September 19, 11
We can download the
                             file just in one
                                 request!




Monday, September 19, 11
Finally , because of the require function used on
                           page has a callback, it can runs after all the files
                                   is received and finish excuting.




Monday, September 19, 11
That’s all.


Monday, September 19, 11
More..


Monday, September 19, 11
Because we use
                                    python...

                           Local transmission

                           Local plugins

                           Deal with CSS files.

                           ...




Monday, September 19, 11
demix
                           Front-end engineer @ Baidu co.

                           email: demixcn@gmail.com

                           weibo/twitter: @demix

                           Homepage: http://demix.github.com/

                           blog: http://www.cnblogs.com/demix




Monday, September 19, 11
Thank You.


Monday, September 19, 11

Weitere ähnliche Inhalte

Ähnlich wie PyJS intro

Symfony2: Get your project started
Symfony2: Get your project startedSymfony2: Get your project started
Symfony2: Get your project started
Ryan Weaver
 
Rcos presentation
Rcos presentationRcos presentation
Rcos presentation
mskmoorthy
 
Re-Introduction to Third-party Scripting
Re-Introduction to Third-party ScriptingRe-Introduction to Third-party Scripting
Re-Introduction to Third-party Scripting
benvinegar
 
Earning Money with Free Software - Gran Canaria Desktop Summit
Earning Money with Free Software - Gran Canaria Desktop Summit Earning Money with Free Software - Gran Canaria Desktop Summit
Earning Money with Free Software - Gran Canaria Desktop Summit
Frank Karlitschek
 
Becoming a Real Programmer
Becoming a Real ProgrammerBecoming a Real Programmer
Becoming a Real Programmer
Jacques Woodcock
 

Ähnlich wie PyJS intro (19)

Embedjs
EmbedjsEmbedjs
Embedjs
 
Vladimir Oane
Vladimir OaneVladimir Oane
Vladimir Oane
 
Erlang for video delivery
Erlang for video deliveryErlang for video delivery
Erlang for video delivery
 
Introducing Mulberry
Introducing MulberryIntroducing Mulberry
Introducing Mulberry
 
Caching, sharding, distributing - Scaling best practices
Caching, sharding, distributing - Scaling best practicesCaching, sharding, distributing - Scaling best practices
Caching, sharding, distributing - Scaling best practices
 
Ruby on Windows (RubyConf.tw 2011)
Ruby on Windows (RubyConf.tw 2011)Ruby on Windows (RubyConf.tw 2011)
Ruby on Windows (RubyConf.tw 2011)
 
has("builds")
has("builds")has("builds")
has("builds")
 
01 Mobile Web Introduction
01 Mobile Web Introduction01 Mobile Web Introduction
01 Mobile Web Introduction
 
Angrybirds - Overview for a High Performance Shop
Angrybirds - Overview for a High Performance ShopAngrybirds - Overview for a High Performance Shop
Angrybirds - Overview for a High Performance Shop
 
Symfony2: Get your project started
Symfony2: Get your project startedSymfony2: Get your project started
Symfony2: Get your project started
 
Rcos presentation
Rcos presentationRcos presentation
Rcos presentation
 
Rubypalooza 2009
Rubypalooza 2009Rubypalooza 2009
Rubypalooza 2009
 
A Re-Introduction to Third-Party Scripting
A Re-Introduction to Third-Party ScriptingA Re-Introduction to Third-Party Scripting
A Re-Introduction to Third-Party Scripting
 
Re-Introduction to Third-party Scripting
Re-Introduction to Third-party ScriptingRe-Introduction to Third-party Scripting
Re-Introduction to Third-party Scripting
 
What's in a number?
What's in a number?What's in a number?
What's in a number?
 
Earning Money with Free Software - Gran Canaria Desktop Summit
Earning Money with Free Software - Gran Canaria Desktop Summit Earning Money with Free Software - Gran Canaria Desktop Summit
Earning Money with Free Software - Gran Canaria Desktop Summit
 
Big app design for Node.js
Big app design for Node.jsBig app design for Node.js
Big app design for Node.js
 
From stock to Cyanogenmod: The Sony Ericsson Case
From stock to Cyanogenmod: The Sony Ericsson CaseFrom stock to Cyanogenmod: The Sony Ericsson Case
From stock to Cyanogenmod: The Sony Ericsson Case
 
Becoming a Real Programmer
Becoming a Real ProgrammerBecoming a Real Programmer
Becoming a Real Programmer
 

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

PyJS intro