Move JavaScript serialization to own component

Bug: 66420
Change-Id: Ideea6750a56b9a8d16de9d8b93999525d0c1c69a