문제

If you have a separate .js file, you may simply compress it with tools such as Yahoo YUI Compressor.

But, how can I compress embedded Javascript in every pages in my project?

(Copying the Javascript to a separate file, then compress, and then copy back to my page cannot be a professional solution for obvious reasons for a medium or big project)

도움이 되었습니까?

해결책

You would normally have a build process which turns the source into a deployable form. This would include any compilation, unit tests, compression etc.

YUI compressor has a build tool for just that http://yuilibrary.com/download/builder/

Also check out ANT http://ant.apache.org/

다른 팁

You could run a backend process that parses your html files, extracts the javascript code and inserts the compressed one. But in any case I would recommend you to seperate all your js into js files. This is it will be easier for you to maintenance in the future.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top