Как применить Google Closure к моей всей веб-странице?

Если Вы используете.NET 3.5, взглянули на Счетное. Метод броска. Это - дополнительный метод, таким образом, можно назвать его непосредственно в Списке.

List<string> sl = new List<string>();
IEnumerable<object> ol;
ol = sl.Cast<object>();

Это не точно, что Вы попросили, но должны добиться цели.

Редактирование: Как отмечено Zooba, можно тогда назвать ol. ToList () для получения Списка

5
задан Maiku Mori 11 January 2010 в 11:33
поделиться

2 ответа

Minifiers,obfuscators and compressors have been designed to solve the issue of downloading external elements when loading a page. They were never meant to be used for inline JavaScript or CSS since lots of that is normally kept outside of the page in a separate file.

Since you should be gzipping as much as you can, for browsers that can handle gzip, it shouldn't in reality matter that your inline css/javascript isn't minified on the page.

2
ответ дан 15 December 2019 в 06:28
поделиться

Если вы используете PHP, вы можете вызвать таким образом компилятор google, а затем использовать заголовок для возврата javascript

<?php
    $script = file_get_contents('http://www.domain.com/scripts/script.js');
    $ch = curl_init('http://closure-compiler.appspot.com/compile');

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, 'output_info=compiled_code&output_format=text&compilation_level=SIMPLE_OPTIMIZATIONS&js_code=' . urlencode($script));
    $output = curl_exec($ch);
    curl_close($ch);

    header('Content-type: application/javascript');
    echo $output;

?>

link php code

1
ответ дан 15 December 2019 в 06:28
поделиться
Другие вопросы по тегам:

Похожие вопросы: