/    Sign up×
Community /Pin to ProfileBookmark

add multiple scritps at one

I have some *.js files. How can I import all in one instead of each individual file using <script></script> tag

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Suhas_DhokeApr 21.2007 — Hello letdoit.

First create an array of all JS filenames and assign all the JS filenames to smarty variabe in PHP file.

And using the [B][COLOR="DarkRed"]foreach loop[/COLOR][/B] on the smarty variable in your html file, you can add all those JS files.

like this.

{if !empty($javascript_arr)}

{foreach from=$javascript_arr item = file_name}

<script language='JavaScript' type='text/javascript' src='{$file_name.src}'></script>

{/foreach}

{/if}

Enjoy.
×

Success!

Help @letdoit spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...