restructured file to generate js script from php