WinJs in the browser?
Asked Answered
R

5

28

After playing a bit with the new Visual Studio 11 preview, I think the most interesting question is how can I make my new javascript based app run also in the browser with minimal changes? is that possible? I suppose the idea of supporting javascript is for better cross-platform apps, am I right?

I understand some of the winJs code calls the WinRT, but can we use some of the WinJS code on web-based apps too?

Resonance answered 15/9, 2011 at 21:13 Comment(2)
I think it's possible, you'd have to go over the library and fake the winrt calls, replace all ms- prefixes with the browser specific one... Out of this I think we'd get something that is working, but only on modern browsers. I'm personally very interested in getting the semantic zoom control to work in regular web =)Ropedancer
There would be a bit more work than to just 'fake' WinRT calls. You'd have to 'replace' the ones you use. But definitely doable since you can start w/ just what you use at first.Propertius
R
18

It seems like things have changed. WinJS has become available on all platforms... You can try it in the browser here: try.buildwinjs.com

WinJS is actually being open source now: blog, github

Use this powerful Windows development framework to build high-quality web apps across a variety of browsers and devices beyond Windows, including Chrome, Firefox, Android, and iOS.

Rubstone answered 2/4, 2014 at 21:40 Comment(3)
And v3 is out which has better support: blogs.windows.com/buildingapps/2014/09/17/winjs-everywhereEmu
To replicate the samples at try.buildwinjs.com locally, you can use the required JS references from cdnjs: cdnjs.com/libraries/winjs . This is the first sample I've found of WinJS being used in a standalone browser app - apptastic.laurenraeorsini.com . It is basic but it shows how to put the pieces togetherChelsea
Check out preview version of v4 github.com/winjs/winjs#build-winjs. WinJs is a SERIOUS competitor to other hybrid frameworks at this point.Latent
A
28

I'm here at build and based on what the Microsoft guys have said is that WinJS does call into the Windows RT. Plus some of their stuff is based on some vendor prefix css stuff (ie IE10 only). So short answer is no, you can't.

More thoughts. To be clear, going from an existing Html/Js app to Win8 should just work. Some considerations of the Win8 App events, and the look and feel are some issues to be concerned about. But the core should work.

The original question is not to dissimilar than, "I have an IE9 HTML5/Js app that I want to run everywhere (including IE6, FF2), Is it possible?" There is a lot of functionality in their libraries, as well as there leveraging of new CSS3 features (-ms-grid, -ms-float, 3d transforms). As far as I know, all their gesture recognition stuff is in the winRT, for "fast and fluid" responsiveness, none of that you can really use outside the Metro environment.

In my opinion, the reason why win8 Metro-style apps is being supported, is not because of cross-platform apps, but to increase the developer base on who can write win8 apps.

Apteryx answered 15/9, 2011 at 21:19 Comment(4)
On the other hand, you are not required to use WinJS, even though it helps a lot in practice.Faletti
So do you think C# will stay the mainstream? would javascript implantation end up like J# did?Resonance
@CD I think C# will remain mainstream initially. For many, C# is easier and more familiar. But, Javascript probably has a better chance of being the main language for win8 metro apps in the future. What better way to learn Javascript, then by making an app, and getting rich? If you don't get rich (most won't), you still have the added benefit of how to be effective with html5/css3 and javascript.Apteryx
What would be nice is if we could create a website using WinJS that runs as well as the new Outlook.com, or Skydrive.com.Archespore
R
18

It seems like things have changed. WinJS has become available on all platforms... You can try it in the browser here: try.buildwinjs.com

WinJS is actually being open source now: blog, github

Use this powerful Windows development framework to build high-quality web apps across a variety of browsers and devices beyond Windows, including Chrome, Firefox, Android, and iOS.

Rubstone answered 2/4, 2014 at 21:40 Comment(3)
And v3 is out which has better support: blogs.windows.com/buildingapps/2014/09/17/winjs-everywhereEmu
To replicate the samples at try.buildwinjs.com locally, you can use the required JS references from cdnjs: cdnjs.com/libraries/winjs . This is the first sample I've found of WinJS being used in a standalone browser app - apptastic.laurenraeorsini.com . It is basic but it shows how to put the pieces togetherChelsea
Check out preview version of v4 github.com/winjs/winjs#build-winjs. WinJs is a SERIOUS competitor to other hybrid frameworks at this point.Latent
R
5

Yes, this is done in with lightswitch html components.

You can download and install lightswitch to see examples of using winjs cross browser. It uses promise objects etc.

Roselynroseman answered 29/11, 2012 at 4:13 Comment(1)
Just to clarify - while LightSwitch does support the creation of cross-platform. cross-browser mobile HTML clients, and leverages a subset of WinJS, it does not appear to use any WinRT specific API calls (which are specific to Win8).Boutique
O
3

There is an alternative to winjs which should work in browsers: http://www.bluesky.io/ didn't tried it yet though.

Ostyak answered 28/4, 2013 at 11:23 Comment(0)
G
2

If you are writing games this would be possible, you can easily port them between a metro app and a web app without having to change a letter of code. This is because you don't really make use of the WinJS library.

For web apps I wouldn't advice it, because this would mean you can't make use of the WinRT framework. It would also mean you loose a lot of functionalities. For example what with search and share charms. These are essentially for a Metro app, but have no use in a web application.

The WinRT framework is also optimized for performance. So it is advised that you use that instead of a framework like jQuery or an other framework. The would probably be slower.

An other question you have to ask your self: If you can write it for the web, why would you want to turn it into a Metro app? What would be the value of that?

A last point I want to make is the following: Web apps are (for now) intended to work online. When working with a metro app you need to keep in mind that the application needs to work offline as well. This means an extra abstraction.

Like Andre mentioned in his answer. HTML5/JS only provides an extra way to develop an application. Microsoft just made it possible that more people could write apps in the language they feel familiar.

Gotthard answered 16/8, 2012 at 19:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.