# How do I export / import a Javascript function into Cakephp?

**URL:** <https://discourse.cakephp.org/t/how-do-i-export-import-a-javascript-function-into-cakephp/8663>\
**Category:** Need Help\
**Created:** [November 26, 2020, 7:32pm UTC](https://discourse.cakephp.org/t/how-do-i-export-import-a-javascript-function-into-cakephp/8663 "2020-11-26T19:32:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bichomen](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/bichomen/32/1070_2.png) [@bichomen](https://discourse.cakephp.org/u/bichomen)\
**Post date:** [November 26, 2020, 7:32pm UTC](https://discourse.cakephp.org/t/how-do-i-export-import-a-javascript-function-into-cakephp/8663/1 "2020-11-26T19:32:15Z")

</div>

Hi,

How do I export / import a Javascript function into Cakephp?

Do I need a JavaScript framework like Node or WebPack?

I have tried this with no luck:

```
1.js
export function ()

2.js
import * as function from './js/1.js';
```

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [November 27, 2020, 12:46am UTC](https://discourse.cakephp.org/t/how-do-i-export-import-a-javascript-function-into-cakephp/8663/2 "2020-11-27T00:46:39Z")

</div>

What do you mean by “export / import a JavaScript function into Cakephp”? In general JavaScript runs on the client, and PHP runs on the server, so they don’t interact.

---

<div class="post-metadata">

**Author:** ![bichomen](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/bichomen/32/1070_2.png) [@bichomen](https://discourse.cakephp.org/u/bichomen)\
**Post date:** [November 27, 2020, 8:05am UTC](https://discourse.cakephp.org/t/how-do-i-export-import-a-javascript-function-into-cakephp/8663/3 "2020-11-27T08:05:19Z")

</div>

I know but since it doesn’t work, I thought something might be happening with CakePHP

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [November 27, 2020, 2:33pm UTC](https://discourse.cakephp.org/t/how-do-i-export-import-a-javascript-function-into-cakephp/8663/4 "2020-11-27T14:33:19Z")

</div>

Since it’s not even clear what you’re trying to do, it’s even less clear what “it doesn’t work” means, and therefore we have no way to tell you whether it’s in any way related to CakePHP or how to fix it. If you can provide more details about what you mean to accomplish, and what isn’t working about it, that may change.
