Search code examples
javascripttestingcompressionlive

How to work with JavaScript in development then live


I work on front end development and am looking to find a solution for working with javaScript between (non compressed and multiple files) development environment and (compressed and combined files) live environment.

I have found a solution with CSS which means that I only need to include one global CSS file with imports, then we combine and compress those imports when deploying to a live environment. This means that we don't have to toggle adding references in to the head for dev and live.

Any ideas on a similar solution for JavaScipt?

Thanks

Dave


Solution

  • Thanks for all your responses. I have come up with a solution which uses some of your ideas.

    i have a global js file which has a list of files to include and when run during dev just writes the script links to the page.

    Then included in the deployment process is a script which parses the global js file, looks up which files it is linking together, combines and compresses them in to one global js file.

    This means that I don't need any server side code during the process which makes things easier to maintain across a team of freelance front end devs.

    i'll post the final bunch of code when it's ready on my blog.