Login

Sign Up

  • Account Information
  • Company Information
  • Contact














* Whale Eco Distribution Agreement

Leave empty when commercial agreements with individual device manufactures are required. Individual agreements overrule the default scope for app distribution.

Already have an account ?Click here to login

Forget Password

Making use Javascript

Strictly speaking, this paragraph is about the ECMA-262 standard and the DOM standards as mandated by HTML, plus extras. In this document, it will be referred to as Javascript.

In terms of writing code, it is important to optimize the code as much as possible for the Smart TV platform which is much less performing than an average PC platform (on average it can be compared to a 300MHz PC,  but with advanced video and audio codes). 

In general, optimization of code for speed can be accomplished by avoiding complex, compound statements. Nested loops should be 'rolled out' as much as possible. Website compression is not always that helpful, as much of the mainstream compression technologies are aimed at a fast PC platform. However, filtering out unnecessary tags and CSS code, as often generated by HTML authoring frameworks can be useful.

For the functionality delivered by the various Javascript APIs in the Smart TV platform,  you do not need to include any specific client-side Javascript libraries.


Try to execute all Javascript functions starting in the body-onload.



If you execute code outside the-onload, be aware that the timing between the Smart TV platform and a PC (SDK) differs: e.g. a DIV-element that you call in your Javascript code could still be loading and thus not be present in the DOM-tree. This would cause Javascript errors, with as symptom that your code works on a fast PC, but not on the Smart TV platform. The solution is to either postpone your code using a setTimeout() or simply call your code from within a-onload function. 

However, be careful with-onload functions, since the page will not be shown (completely) until all onload functions have been executed. Try not to execute all Javascript code at once, but use e.g. a timeout-timer to execute the code after a few seconds.

Code sample of how you should not call your Javascript:


<script type = "text/javascript">
   function myNonWorkingFunction(){
   myNonPressentDiv.innerHTML = "My nonworking text";
}
      myNonWorkingFunction();
</script>
</head>
<body>
    ......
    My initial text
</body>


Correct code sample, using body-onload:

<script type = "text/javascript">
   function myWorkingFunction(){
   myPressentDiv.innerHTML = "My working text";
}
</script>
</head>
<body onload = "myWorkingFunction();">
     ......
     My initial text
</body>


How to use Timers?



In an App, Javascript allows a developer to create dynamic pages. In a PC environment, Javascript can be used for rapid dynamic page changes, such as animations. For this purpose, timers are used that have a very low granularity.

In an embedded environment, timers are typically not practical to use for values less than 1 second, as the system is simply too slow to keep up. Usage of many timers at once on the same page has the same implications: it does not work smoothly on an embedded system. 

Generally, such effects should be kept to a minimum, as any form of animation can be expensive in terms of performance, potentially rendering sites and applications slow and unresponsive.

it is worth considering the use of new CSS3 capabilities such as transitions and transforms. 


Do we use Eval?



You should NOT use eval, except for use in JSON. Eval in general is bad coding practice. Parsing would take additional time if done with a JSON parser. In times, depending on the size of the JSON response, a wise choice should be made.


Can we use popups?



As the browser only supports one window, popups are NOT supported. (e.g. window.open )





Interested in becoming an Zeasn partner?
We’d love to hear from you.
Copyright © 2011 -2023 Beijing Zeasn Information Tech CO., Ltd. All Rights Reserved