开发者

JavaScript Interfaces, Imports - When? (I want to port something from AS3)

). I was eagerly waiting for JavaScript 1.8.5 only to find out it brings very little to the table. ActionScript 3 is ECMAScript 5 compliant, but apparently Interfaces aren't?

When will JS have some decent OO support? I consider Interfaces to be very important for type safety.

I also have another question, regarding the ability to "import" folders/classes in a file, which is done in AS3 using the "import" statement. Now, I'm aware that this is all related to the AS3 compiler, but I got a rather large project (a game) which I want to port to HTML 5 using JS and I am worried about how my code will be o开发者_运维问答rganizable.

It's rather hard to include 50 classes in a web page (supposedly, the page where the HTML5 version of the game will be located), don't you think?

What would you do?


Regarding the part about handling multiple javascript files. You could use a web resource optimizer like wro4j.

Using it you would specify groups like this:

<group name="group1">
  <js>file1.js</js>
  <js>file2.js</js>
  <js>file3.js</js>
  <js>file4.js</js>
  <css>file1.css</css>
  <css>file2.css</css>
  <group-ref>some-other-group</group-ref>
</group>

And inside the html page you would import a group like this:

<link rel="stylesheet" type="text/css" href="/wro/group1.css" />
<script type="text/javascript" src="/wro/group1.js"></script>

Beside just grouping and joining multiple files like this it can also minify the code, gzip and handle caching.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜