alidads alidads - 29 days ago 7
jQuery Question

how to connect to jquery in other page

one of home PHP page have so many jquery's lines like this...

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script src="https://use.fontawesome.com/5b3a8fc5cd.js"></script>
<script src="js/main.js"></script>


And I'm trying to clear up the codes and make organized the code, I was wondering if this will work by put all jquery's lines into other page and put the name as all.jquery.js! if so how can I link from home page to all.jquery.js..?

I have tried using
<script src="js/all.jquery.js"></script>
in home page and is not working.

what did I miss!

Alidad

Answer

You cannot source an html file as a script.

But you can use RequireJS which basically calls all JS files from a specified path.

<script data-main="scripts/all.js" src="scripts/require.js"></script>

Then you call the rest of the JS files inside “all.js” –

Read http://requirejs.org/docs/api.html#jsfiles on how to call your JS files accordingly.

Comments