DukeScript, why using @JavaScriptResource rather than importing a js resource with <script>?

怎甘沉沦 提交于 2019-12-13 03:46:43

问题


Quote from Using the Knockout API

Define a class JQuery and add the JavaScript-library to your project. Now you can reference it using @JavaScriptResource. This is how you manage JavaScript libraries in DukeScript

Is that any different from including a javascript file with the <script> tag inside an html page? I've tried both and couldn't see why using the annotation @JavaScriptResouce would be any different.


回答1:


The main idea of @JavaScriptRessource is to use it for defining your own Java API over a javascript library, e.g. the API for knockout.

With "script" it would be the users responsibility to provide the correct version. With @JSR the user of the API doesn't have to know anything about the required JS-file. Instead you deliver the correct version with the API. The user of the API only has to deal with Java.

If you use JS only for styling&layout (e.g. bootstrap, etc.) it's fine to just add it via "script" tag.



来源:https://stackoverflow.com/questions/30700526/dukescript-why-using-javascriptresource-rather-than-importing-a-js-resource-wi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!