简体   繁体   中英

Using javascript in Symfony2/Twig with external references

In reference to the following post:

Using javascript in Symfony2/Twig

Is there a possibility to include scripts locating on other servers, just as google-api.

The fact that the script is located on an external server doesn't change much. You can still have Assetic handle it like in the example below.

{% block javascripts %}

  {% javascripts 
    'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js'
    '@AcmeDemoBundle/Resources/public/js/demo.js'
  %}

    <script src="{{ asset_url }}"></script>

  {% endjavascripts %}

{% endblock %}

I solved it without the asset-manager,
just including the script statically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM