# New Async Java-Javascript Interop API

DevFeed: [New Async Java-Javascript Interop API](<https://devfeed.tech/articles/new-async-java-javascript-interop-api-19397.md>)

Original publisher: [Read original article](<https://www.codenameone.com/blog/new-async-java-javascript-interop-api/>)

Author: Steve Hannah

Published: 2018-02-13T00:00:00Z

Content type: tutorial

Language: en

Sources: [CodeName One](<https://devfeed.tech/sources/codename-one.md>)

Topics: [API](<https://devfeed.tech/topics/api.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Java](<https://devfeed.tech/topics/java.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [asynchronous](<https://devfeed.tech/tags/asynchronous.md>), [callback](<https://devfeed.tech/tags/callback.md>), [code](<https://devfeed.tech/tags/code.md>), [java](<https://devfeed.tech/tags/java.md>), [javascript](<https://devfeed.tech/tags/javascript.md>)

## AI overview

The article introduces a new asynchronous JavaScript interop API in Codename One's BrowserComponent class. It replaces the deprecated com.codename1.javascript package, addressing the performance, complexity, and predictability costs of the former synchronous API by using callbacks and optional AndWait() wrappers.

## Source excerpt

We recently introduced a new API for interacting with Javascript in Codename One. This new API is part of the BrowserComponent class, and effectively replaces the com.codename1.javascript package, which is now deprecated. So what was wrong with the old API? The old API provided a synchronous wrapper around an inherently asynchronous process, and made extensive use of invokeAndBlock() underneath the covers. This resulted in a very nice API with high-level abstractions that played nicely with a synchronous programming model, but it came with a price-tag in terms of performance, complexity, and predictability. Let's take a simple example, getting a reference to the "window" object: