Transport some init code

from lib to index.html