PyJS intro
-
Upload
demix -
Category
Technology
-
view
2.672 -
download
0
description
Transcript of PyJS intro
![Page 2: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/2.jpg)
A CommonJS Based Javascript Framework
runs on Browser
https://github.com/demix/pyjs
Monday, September 19, 11
![Page 3: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/3.jpg)
CommonJS
Monday, September 19, 11
![Page 4: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/4.jpg)
Math.js
increment.js
program.js(main)
Monday, September 19, 11
![Page 5: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/5.jpg)
Benifits
Monday, September 19, 11
![Page 6: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/6.jpg)
One code , runs everywhere
No need to study and follow an ugly module pattern
Automatic namespace
Monday, September 19, 11
![Page 7: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/7.jpg)
Browser
Server
Desktop
Command line tools
...
Monday, September 19, 11
![Page 8: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/8.jpg)
One code , runs everywhere
No need to study and follow an ugly module pattern
Automatic namespace
Monday, September 19, 11
![Page 9: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/9.jpg)
Traditional Module Pattern
CommonJS Module
Monday, September 19, 11
![Page 10: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/10.jpg)
One code , runs everywhere
No need to study and follow an ugly module pattern
Automatic namespace
Monday, September 19, 11
![Page 11: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/11.jpg)
Monday, September 19, 11
![Page 12: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/12.jpg)
Server side Example:
NodeJS
Browser side Example:
Firefox jetpack project
Examples
Monday, September 19, 11
![Page 13: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/13.jpg)
Problem
Monday, September 19, 11
![Page 14: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/14.jpg)
Run directly after ‘require’.No Callback.
Monday, September 19, 11
![Page 15: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/15.jpg)
Means in Browser, we can only use
“Synchronous”
request to get the script file.
Monday, September 19, 11
![Page 16: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/16.jpg)
What’s the fxxk...
Monday, September 19, 11
![Page 17: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/17.jpg)
SeaJS
Monday, September 19, 11
![Page 18: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/18.jpg)
Monday, September 19, 11
![Page 19: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/19.jpg)
User pre-defined template wrapper.
Prefetch Js file which has been required.
How it works
Monday, September 19, 11
![Page 20: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/20.jpg)
Problems
Still ugly template.
Still can’t download all files in parallel
Monday, September 19, 11
![Page 21: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/21.jpg)
PyJS
Monday, September 19, 11
![Page 22: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/22.jpg)
Grammar
Monday, September 19, 11
![Page 23: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/23.jpg)
99% same as CommonJS API
No ugly user pre-defined template wrapper
Monday, September 19, 11
![Page 24: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/24.jpg)
what about the file loading problem?
You haven’t mentioned it ..
Monday, September 19, 11
![Page 25: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/25.jpg)
There is two loading rules in PyJS.
One in local debugging,
the other in online building.
All need Python environment.
Monday, September 19, 11
![Page 26: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/26.jpg)
python pyjs.py runserver
Fetch the JS file in synchronous XHR request.
Server will parse the module file automaticly
Local debugging
Monday, September 19, 11
![Page 27: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/27.jpg)
Server parse
Monday, September 19, 11
![Page 28: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/28.jpg)
Online buildingpython 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
![Page 29: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/29.jpg)
Then , if we had a combo service like:
Monday, September 19, 11
![Page 30: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/30.jpg)
We can download the file just in one
request!
Monday, September 19, 11
![Page 31: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/31.jpg)
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
![Page 32: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/32.jpg)
That’s all.
Monday, September 19, 11
![Page 33: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/33.jpg)
More..
Monday, September 19, 11
![Page 34: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/34.jpg)
Because we use python...
Local transmission
Local plugins
Deal with CSS files.
...
Monday, September 19, 11
![Page 35: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/35.jpg)
demixFront-end engineer @ Baidu co.
email: [email protected]
weibo/twitter: @demix
Homepage: http://demix.github.com/
blog: http://www.cnblogs.com/demix
Monday, September 19, 11
![Page 36: PyJS intro](https://reader038.fdocuments.in/reader038/viewer/2022102721/54b514aa4a7959202e8b4651/html5/thumbnails/36.jpg)
Thank You.
Monday, September 19, 11