简体   繁体   中英

Where to put JavaScript files in a Symfony2 project?

I have a Symfony2 project and I have some JavaScript code to be executed.

Where should the .js file be stored in the project and how to call this file (instead of putting the entire script in the .twig )?

Put it in web/js , then access it in your html via:

<script src="{{ asset('js/script.js') }}"></script>

or consider using Assetic .

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