Node.js and HTML5 develop local desktop applications _node.js

Source: Internet
Author: User
Tags zip

HTML5 makes it possible for web developers to develop rich-client Internet applications with pure HTML technology or even local desktop applications. HTML5 can transform any ordinary Web site into a Web application. HTML5 Web Apps not only have the advantage of desktop browser applications, but also the development of smart phones and tablets is a tool.

On the phone side, there is a great tool called PhoneGap, using this rapid development platform, anyone can use Html5+css3+javascript to develop Android, iOS and other applications. One of the best features of PhoneGap is that you don't need to be networked, you don't need to connect to a Web server, you can use it as a local desktop application. Once downloaded to local, it can be used offline as well as native applications.

We usually feel that there are a lot of interesting HTML applications on the Web, but these apps need you to open the browser and enter the URL. In fact, we prefer a direct click on the desktop icon to start a program of this experience. The local desktop application developed with HTML5+JS is to improve the user experience, and in addition to the phonegap mentioned above, there are a few such as Pokki and chrome Package apps or Mozilla XUL Runner are the framework for developing HTML5 local desktop applications.

Pokki and chrome can be used not only to develop HTML5 desktop applications, but also to sell them in the trading market.

Another interesting tool is Node-webkit, which is the main topic of this article.

Node-webkit is a platform based on chromium and node.js operations. It allows you to install HTML5 applications or games into Windows, Linux, or Mac systems with packaged costs. The Node-webkit project was developed by Intel Open Source Technology Center, and the initiator is Wang Wenrui.

Why Node-webkit is the best choice for developing HTML5 local desktop applications

    1. Node-webkit can apply your HTML5 to desktop applications packaged on Windows, Linux, or Mac platforms, and you can run your HTML5 applications independently without the need for other dependencies.
    2. It supports Node.js. You can use all of Node.js's modules to develop your favorite app or game. Not only can you use the Node.js native module, but you can use a third party node.js module.

How to use Node-webkit to develop HTML5 local desktop applications

This is very simple, like the traditional development of your HTML5 application to develop them, finished with Node-webkit package it. The way to package is

1. Download Node-webkit First

2. Then create a package file named Package.json and write the following code:

{
 ' name ': ' Nw-demo ',
 ' main ': ' Index.html '
}

"Name" Here is the name you apply, "main" is the startup file for your application, that is, the application startup is the first loaded file.

3. Package your HTML5 application file and Package.json together into a zip

4. Rename the zip file, and then change the suffix to. NW, such as APP.NW.

5. Now you can use Node-webkit runtime to run your app. The command to run on Linux is

./NW APP.NW

On the Windows platform you can simply drag your app.nw onto the Nw.exe program.

6. To make your application easier to spread and publish, you can encapsulate it with Node-webkit, which is to combine your HTML5 application app.nw and Nw.exe to synthesize an executable file. The practice on Linux is

CAT/USR/BIN/NW app.nw > App && chmod +x app

The practice on the window is

copy/b NW.EXE+APP.NW App.exe

You can take a look at this wiki document, which is described in more detail. I hope this article will be of some help to you.

Thank you for reading, I hope to help you, thank you for your support for this site!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.