how to add <script> in <header>

Maxim Dounin mdounin at mdounin.ru
Tue Dec 29 13:17:03 UTC 2015


Hello!

On Tue, Dec 29, 2015 at 05:07:37PM +0800, 天河石 - 谢金鹏 wrote:

> I like to add the following entry:
> 
> 
>  <script type="text/javascript" async="async" src="http://www.google-analytics.com/ga.js"></script>
> 
> 
> in <head> section. How do I do it?

Assuming you want to do it using nginx, try something like this:

    sub_filter '</head>'
               '<script type="text/javascript" async="async" src="http://www.google-analytics.com/ga.js"></script></head>';

See docs here for details:

http://nginx.org/en/docs/http/ngx_http_sub_module.html

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list