简体   繁体   中英

Is .js extension needed for Javascript files in browser?

Can things like <script type="text/javascript" src="/actions/generateScript"></script> be used without troubles?
It's kinda hard and tricky to setup server for processing urls with extensions, so maybe I just don't need them.

No, it's not needed. Browser just tries to download resource from src and execute it as JS code.

I once have use .php file as CSS source and it worked fine

不,因为你已经有了“script type =”text / javascript“浏览器知道你正在尝试加载.js文件。此外,现代浏览器无论如何都会运行javascript。

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