WebApp开发工具

Filed in Javascript/DHTML | Mobile 1 Comment

最近折腾了一些开发调试工具,在前端开发中可以大大提升效率和前端性能并使工作流更加顺畅。

1. 基于任务的命令行构建工具Grunt
类似于Jake,支持以下预定义任务:
concat – 合并文件
init – 从预定义模板生成项目框架结构
lint – 用JSHint校验文件
min – 用UglifyJS压缩文件
qunit – 用无头PhantomJS实例运行QUnit单元测试
server – 开启一个静态Web服务器
test – 用nodeunit运行单元测试
watch – 当观察的文件改变时运行预定义的任务
安装(确保node和npm已经安装):npm install -g  grunt-cli
假定我们只对现有的项目做合并、压缩和校验的工作,那么可以先创建一个package.json和Gruntfile.js两个文件
package.json基于Packages规范如:
{
“name”: “my-project-name”,
“version”: “0.1.0″,
“devDependencies”: {
“grunt”: “~0.4.1″,
“grunt-contrib-jshint”: “~0.1.1″,
“grunt-contrib-uglify”: “~0.2.0″,
“grunt-contrib-concat”: “~0.1.3″,
“grunt-contrib-nodeunit”: “~0.1.2″
}
}
安装Grunt和Grunt插件:npm i grunt grunt-contrib-nodeunit grunt-contrib-concat grunt-contrib-jshint grunt-contrib-uglify –save-dev

Gruntfile.js是一个在项目根目录下的JavaScript文件,这个文件由下面组成:
“封装”函数、项目和任务配置、加载Grunt插件和任务、自定义任务,
如下:
module.exports = function(grunt) {
//project configuration
grunt.initConfig({
pkg: grunt.file.readJSON(‘package.json’),
concat: {
main: {
src: ['config.js', 'jquery-1.8.2.min.js', 'core.js'],
dest: ‘build/main.js’
},
css: {
src: ['css/Main.css', 'css/App.css'],
dest: ‘build/css/main.css’
}
},
jshint: {
main: {
src: ‘build/main.js’
}
},
uglify: {
build: {
src: ‘build/main.js’,
dest: ‘build/output/main.js’
}
}
});
grunt.loadNpmTasks(‘grunt-contrib-concat’);
grunt.loadNpmTasks(‘grunt-contrib-jshint’);
grunt.loadNpmTasks(‘grunt-contrib-uglify’);
grunt.registerTask(‘concat’, ['concat']);
grunt.registerTask(‘jshint’, ['jshint']);
grunt.registerTask(‘uglify’, ['uglify']);
};
具体每部分的作用请看官网介绍。

这样就注册了三个任务,只要在控制台运行grunt concat,运行结果大致如下:
Runing “concat:main” (concat) task
File “build/main.js” created.
Running “concat:css” (concat) task
File “build/css/main.css” created.
Done, without errors.

同样可以运行grunt jshint和grunt uglify来校验和压缩文件。

2. WebStorm
WebStorm是一个强大的前端开发IDE,这里有比较详细的介绍

3. YUIDoc
文档是保证项目可维护必不可少的环节,YUIDoc是一个基于NodeJs的文档生成工具。YUIDoc会解析JavaScript的注释块,所以需要按照YUIDoc提供的语法来写您的注释,如:
/**
* 类的描述
* @class MyClass
* @constructor
*/
/**
* 方法描述
* 可以是多行
* @method methodName
* @param {String} foo Argument 1
* @param {Object} config A config object
* @param {String} config.name The name on the config object
* @param {Function} config.callback A callback function on the config object
* @param {Boolean} [extra=false] Do extra, optional work
* @return {Boolean} Returns true on success
*/
之后在你的项目根目录运行yuidoc .即可,如果你想实时看你修改的情况,可以运行yuidoc –server 5000以服务器模式运行,然后访问http://127.0.0.1:5000/当你刷新浏览器时就会看到反应。

4. Chrome开发者工具
Chrome的开发者工具变得越来越强大,最新版不仅支持”Scroll into View”(在Elements里选择后点击页面会跳转到对应位置),还可以在右侧栏点击”Toggle Element State”观察元素:hover :active时的样式。
在Mobile开发方面,点击右下角的设置可以设置”User Agent” “Device Metrics” “Geolocation” “Touch Events”等方便调试,同时要善于利用Profiles来检测内存泄露和DOM泄露。
如果你想跟随潮流,那不妨使用Chrome Canary进行开发和调试。
Chrome还提供了一些配置,如chrome://flags,你可启用”合成渲染层边框”来看webkit的渲染层

Fluent 2012会议记录

Filed in HTML5 | Javascript/DHTML | Mobile 1 Comment

Fluent会议都是关于JavaScript的,在Youtube上看了Fluent 2012的视频,觉得JavaScript发展越来越成熟。

比如Ben Galbraith & Dion Almaer讲的”Web vs. Apps”提到了:”Native apps must die”,  ”Path应用程序上传通讯录导致的不安全”, “amazing ecosystem的出现如ember.js, node.js, backbone…”。

Steve Souders的 “Your Script Just Killed My Site”提到了一些性能分析工具如http://www.webpagetest.org/也很强大。

Paul Irish的”Javascript Development Workflow of 2013″描绘了前端开发一系列工具如SublimeLinter, Yeti, qunit, gruntjs等。

Axel Rauschmayer的”Improving JavaScript”介绍了在ES5中JavaScript有了哪些提升如”function-scoped variable”, “inadventent sharing closure”, “class declaration”等问题。

另外还有很多JavaScript应用方面的Startup Showcase,我列举了一下:

1. https://kanban2go.com/

The art of getting things done.

 

2. http://gameclosure.com/

With the Game Closure SDK you create games in JavaScript that run on many devices—web browsers, mobile phones, and tablets.

 

3.  http://ludei.com/

Mobilizing HTML5 Games

 

4. http://www.appcelerator.com/

Appcelerator Titanium is the leading cross platform mobile development solution for native, hybrid and mobile web applications.

 

5. https://pubnub-prod.appspot.com/

PubNub is a blazingly fast cloud-hosted real-time messaging system to push real time data to web, tablet and mobile devices.

 

6. http://www.infragistics.com/

Infragistics is your source for User Interface (UI) controls and components for .NET, ASP.NET, Windows Forms, WPF, Silverlight, jQuery, ASP.NET MVC, Reporting and Mobile.

 

7. http://wijmo.com/

Wijmo is a complete kit of over 40 UI widgets with everything from interactive menus to rich charts. If you know jQuery, you know Wijmo.

 

8. http://enyojs.com/

Truly cross-platform. Use the same framework to develop apps for the web and for all major platforms, desktop and mobile.

9. http://www.devchix.com/

An international group of female programmers working to make the tech community a better place for everyone.

 

10. http://appendto.com/

The company dedicated to jQuery.

 

11. http://www.deployd.com/

Deployd is a tool that makes building complex backends simple. Build realtime APIs for web and mobile apps in minutes instead of days.

 

12. http://incubator.apache.org/cordova/

Apache Cordova is a platform for building native mobile applications using HTML, CSS and JavaScript.

 

13. http://phonegap.com/

Developing with PhoneGap gives you the freedom to create mobile applications for iOS, Android, Blackberry, Windows Phone, Palm WebOS, Bada and Symbian using the web code you know and love: HTML, CSS and Javascript.

 

14. https://monotask.com/

Monotask is simple attention management software. It helps you get your work done more efficiently, spend more time on the things you’re passionate about, and make more money.

 

15. https://www.picplum.com/

Picplum prints your photos and ships them to your family & friends automatically every month.

 

16. https://stackmob.com/

StackMob’s mobile platform helps developers create a  mobile business by letting them easily build, deploy and grow full-featured applications from the very first version. StackMob cuts backend development time from months to minutes, letting developers focus on creating powerful apps with quality user experiences. StackMob also provides a hosted HTML5 solution which makes it the most robust and flexible end-to-end platform in the market.

 

17. http://www.xtuple.com/

xTuple open source ERP is business software for small to medium-sized businesses (SMBs). If you’ve reached the limits of Quickbooks, PostBooks can help.

 

18. http://www.sencha.com/

Sencha provides web app frameworks and tools to help developers build HTML5 apps the look and feel native and run on any device.

 

, ,

HTML5 on Mobile

Filed in HTML5 | Mobile 2 Comments

在淘宝技术沙龙上的演讲视频:

HTML5 on Mobile (For Designer)

Filed in HTML5 | Mobile 1 Comment

I Introduced some HTML5 features on mobile and how to build and design the mobile web page from the perspective of designer in today’s share meeting.

Here is the slide in slideshare.net, I’m going to have a topic about “HTML5 on mobile” for developer in future.

, ,

Debugging Mobile Web Page

Filed in HTML5 | Mobile 5 Comments

在PC端的开发中我们拥有很多前端开发调试工具, 但是Mobile端的调试相对比较麻烦一些, 不光要在浏览器上调试, 而且很多都需要在真实的设备上来调试, 设备的类型/制造商/操作系统, 网络环境都会影响Web的调试.

PC上开发

从我的经验来看我一般先是使用Safari的模拟User Agent来开发Mobile Page, 开启Safari, 选择设置, 高级, 显示”开发”工具菜单, 这样你就能在Safari的菜单中看到”开发”了, 然后就可以选择一些User Agent:

但是有时可能还需要模拟Android Safari上的User Agent, 如

Google Nexus One: Mozilla/5.0 (Linux; U; Android 2.1; en-us; Nexus One Build/ERD62) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17 –Nexus

Android Tablet: Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; device Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Safari/533.1

只需要选择”Other”把自定义的User Agent输入进去即可.

模拟器上调试

当然Safari的开发者工具也不比Firebug差, 在桌面的Safari开发完成后, 还需要在模拟器上进行调试, iOS的Simulator需要安装XCodeXCode是用于开发Apple系列产品如Mac, iPhone, iPad上的集成开发环境, 包括IDE, Instruments, iOS Simulator以及最新的Mac OS X和iOS SDK.安装完XCode后, 在/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications这个目录下, 打开iOS Simulator就可以运行了, 界面如下:

这样你就可以看到底部有Safari的浏览器, 通过打开设置->Safari->开发者->高级->调试控制台, 设置为开就可以打开Safari的控制台了, console.log/console.error的输出都会出现在控制台里面.

Android的Emulator安装请参考http://developer.android.com/guide/developing/devices/emulator.html

在模拟器上使用HOST文件

使用模拟器通常需要绑定开发环境的host, iPhone的模拟器会使用你Mac电脑的host文件, 这个比较方便, 而Android的Emulator修改host会比较麻烦, 因为它不会使用你本机的host文件, 下面来说一下怎么修改:

1.在android-sdk/tools/目录下启动Android Virtual Device(AVD): emulator -avd myAvdNameHere -partition-size 128

2. adb remount

3. adb push /etc/hosts /system/etc

设备上调试

最后就是设备调试阶段, 同样iPhone越狱的手机可以在Cydia安装mobile terminal这款软件来修改host文件, Android手机同样也有修改host的方法.

对于Mobile上的调试还有一个很有用的bookmark工具Mobile Perf bookmarklet, 它是由Google的Steve Souders创建的一个针对Mobile的调试工具列表, 如 Firebug Lite, Page Resources, DOM Monster, SpriteMe, CSSess, Zoompf等, 其中有些已经集成了Jdrop(云端Json数据存储平台), 这样就可以很方便地在PC上分析Mobile的数据了, iPhone上的安装请看这里.

远程调试

刚才说了Mobile上的数据不太好分析, 如果能在PC上调试Mobile上的页面就好了, 所以也出现了很多远程调试工具, 下面介绍几个:

1. Weinre, 这是一个很强大的远程调试工具, Weinre是”WEb INspector REmote”的缩写, 通过它你可以在PC上使用Safari的开发者工具来调试Mobile上的页面, 你也可以在线使用http://debug.phonegap.com/或是下载Weinre的客户端软件.

2. Jsconsole, 这是一个Javascript命令行工具, 它也提供了远程调试的功能.

3. Opera Dragonfly, Opera浏览器提供的开发者工具, 也很方便, 如果你的网站是需要兼容Opera的话可以试一下.

4. Socketbug, 建立在Node.jsSocket.IO上的Mobile Web调试工具.

5. Remote Debugging with Chrome for Android, 通过USB调试模式和android sdk自带的工具同时使用chrome的开发工具远程调试android上的页面.

6. Adobe Shadow, 安装了Adobe Shadow后就可以同步手机设备和PC,然后就可以在PC上远端调试Mobile上的页面。

无觅相关文章插件,快速提升流量

, , , , , ,

TOP