In a PHP project using requirejs, if PHP returns some JavaScript code, where should it be placed?

WBOY
Release: 2016-10-10 11:56:18
Original
977 people have browsed it

If I use requirejs in the front end of my php project,
If some php code will return some javascript code snippets that need to be run, where should I put these returned codes? Or how to deal with them?

Always feel that if you spread it out, it will be messy and difficult to maintain?

Or is my handling of php returning javascript code something that shouldn't happen?

My understanding of requirejs is that a page only needs to introduce one js, and this js will handle all things. I don’t know if this is the right understanding, please give me some advice.

I am new to 2333 and have never seen much of the world. Please give me some advice~

Reply content:

If I use requirejs in the front end of my php project,
If some php code will return some javascript code snippets that need to be run, where should I put these returned codes? Or how to deal with them?

Always feel that if you spread it out, it will be messy and difficult to maintain?

Or is my handling of php returning javascript code something that shouldn't happen?

My understanding of requirejs is that a page only needs to introduce one js, and this js will handle all things. I don’t know if this is the right understanding, please give me some advice.

I am new to 2333 and have never seen much of the world. Please give me some advice~

requirejs is an implementation of the AMD modular specification. As far as my development experience is concerned, requirejs is currently used less often, and is generally developed based on the npm ecosystem, that is, the CommonJS specification, or modularization based on the ES6 Module specification. method, and as the author said, returning js code snippets has never been encountered before.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!