How to get a minified JavaScript code from UglifyJS service using jquery.ajax()?
http://marijnhaverbeke.nl/uglifyjs/?js_code=alert(document.title)
The only way (are there alternative ways?) I could get successful response from the service is by using: $.ajax
with dataType: "script"
, so it evaluates the开发者_JAVA技巧 script, but I'd like to get minified script as plain-text.
Any suggests?
You can't, since x-domain AJAX works by executing the code in a similar fasion to including a script tag:
<script src="http://marijnhaverbeke.nl/uglifyjs/?js_code=alert(document.title)"></script>
The only way you can get the minified version of the script contents is to create a proxy method on your local web server that your code can call using plain AJAX; the method only needs to forward the call to the UglifyJS service and return the string received back to the AJAX caller.
精彩评论