# Avoid serving legacy JavaScript to modern browsers

**URL:** <https://community.haxe.org/t/avoid-serving-legacy-javascript-to-modern-browsers/4279>\
**Category:** Haxe\
**Tags:** haxe-js\
**Created:** [July 5, 2024, 11:50am UTC](https://community.haxe.org/t/avoid-serving-legacy-javascript-to-modern-browsers/4279 "2024-07-05T11:50:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaxiHaxe](https://avatars.discourse-cdn.com/v2/letter/m/5fc32e/32.png) [@MaxiHaxe](https://community.haxe.org/u/MaxiHaxe)\
**Post date:** [July 5, 2024, 11:50am UTC](https://community.haxe.org/t/avoid-serving-legacy-javascript-to-modern-browsers/4279/1 "2024-07-05T11:50:01Z")

</div>

Hi all,

I am focusing on performance of javascript and pagespeed.web.dev/ throw me this warning (attachment)

 ![Screenshot 2024-07-05 at 13.45.54](https://community.haxe.org/uploads/default/original/2X/e/eac9ca9f0f7d2cf26904fdd10f86aec9068b0563.png)

([Publiez, livrez et installez du code JavaScript moderne pour des applications plus rapides &nbsp;|&nbsp; Articles &nbsp;|&nbsp; web.dev](https://web.dev/articles/publish-modern-javascript?utm_source=lighthouse&utm_medium=lr))

Haxe generates `String.fromCodePoint()` to the compiled code. Is there any way how to fix it, please?

Thank you

---

<div class="post-metadata">

**Author:** ![RblSb](https://avatars.discourse-cdn.com/v2/letter/r/edb3f5/32.png) [@RblSb](https://community.haxe.org/u/RblSb)\
**Post date:** [July 7, 2024, 2:55pm UTC](https://community.haxe.org/t/avoid-serving-legacy-javascript-to-modern-browsers/4279/2 "2024-07-07T14:55:41Z")

</div>

There should be less polyfills with `-D js-es=6` in general, but for this thing i did PR with fix

> <https://github.com/HaxeFoundation/haxe/pull/11713>

---

<div class="post-metadata">

**Author:** ![MaxiHaxe](https://avatars.discourse-cdn.com/v2/letter/m/5fc32e/32.png) [@MaxiHaxe](https://community.haxe.org/u/MaxiHaxe)\
**Post date:** [July 9, 2024, 3:11pm UTC](https://community.haxe.org/t/avoid-serving-legacy-javascript-to-modern-browsers/4279/3 "2024-07-09T15:11:21Z")

</div>

Thank you, it works, notification from pagespeed.web.dev is gone BUT I check generated code (attachment).

And I am using haxe.Template and there isnt function like fromCodePoint() (left side of attachment) but on my generated code fromCodePoint appeared. I dont know what a part of code is it and when is called but after calling it throw error in console.  
it is likely that this part of the code will never be called? 😃

I dont know why haxe generates function fromCodePoint instead of fromCharCode like is defined in Template.hx. I am using the newest version of Haxe 4.3.4

Thank you

 ![Screenshot 2024-07-09 at 16.55.41](https://community.haxe.org/uploads/default/original/2X/3/38ce8bfda7ac3abea308c53fdc5114de26b35eba.jpeg)

---

<div class="post-metadata">

**Author:** ![RblSb](https://avatars.discourse-cdn.com/v2/letter/r/edb3f5/32.png) [@RblSb](https://community.haxe.org/u/RblSb)\
**Post date:** [July 9, 2024, 3:49pm UTC](https://community.haxe.org/t/avoid-serving-legacy-javascript-to-modern-browsers/4279/4 "2024-07-09T15:49:16Z")

</div>

Yes, `String.fromCharCode` in Haxe has specification like `String.fromCodePoint` in JS, and this is why this method is generated for js target. For example, for `arr.contains()` haxe will generate `arr.includes()` in js output. Haxe just has different methods naming.
