Javascript – How to work with JavaScript in development then live

compressionjavascriptlivetesting

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

Best Answer

If you are using jQuery it's really easy to include external Javascript files from within Javascript which is basically what you described you did with CSS.

Read up on jQuery getScript()