Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encoding issue while integrating Moment JS library

I have recently integrated MomentJS library into my application and have been running into a weird issue. Browser I have to use is IE9.

When I launch the application for the first time with zh-cn locale, I see a few junk characters in place of date and time. When I log out and log in again, then the characters load properly.

I check the encoding on screen and see it is UTF-8 both times. The issue is not consistent. I am at a loss as in what should I do to debug or get to the root of this issue. Any pointers about what I should check would be appreciated.

like image 657
Chiranjib Avatar asked Oct 06 '14 11:10

Chiranjib


People also ask

Is MomentJS tree shaking?

As Moment. js is not supporting tree shaking, it makes no difference if we use many or 1 methods from it.

Is MomentJS deprecated?

js . This library helps you manipulate, validate, and accurately display the date and time according to… In fact moment. js is deprecated, the development team recommends to use date-fns instead.

Why is MomentJS so large?

Since the Moment. js package isn't modularized and, per the threads on Github issues, it won't be done as support is ending and they have termed it a legacy project. This is the primary reason behind those large chunks in the build size.


1 Answers

For integrating the MomentJS library, instead of

<script src="moment-with-locales.js"></script>

use this

<script src="moment-with-locales.js" charset="UTF-8"></script>

like image 129
Chiranjib Avatar answered Oct 25 '22 18:10

Chiranjib