Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Load several javascripts from one library or directory using php / html?

Posted on 2009-04-06
17
Medium Priority
?
786 Views
Last Modified: 2012-05-06
I would like to load several javascripts from one external library or directory. How can I do this with PHP and html in the header of a site? There are several scripts in the same directory I need to be loaded for certain javascript apps to work..
0
Comment
Question by:rhandalthor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 5
17 Comments
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 24077308
Just load them, one by one. Output this as html in the head part of the html output:

<script type="text/javascript" src="onefile.js"></script>
<script type="text/javascript" src="anotherfile.js"></script>
<script type="text/javascript" src="thirdfile.js"></script>
0
 

Author Comment

by:rhandalthor
ID: 24077448
How are scripts loaded here http://tiny.cc/OWIWy ? I don't see a call for every script from Google Apis.com...
0
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 24077642
There are several scripts included on that page. prototype and scriptaculous is loaded at the start:

<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.2/scriptaculous.js" type="text/javascript"></script>

Several others are included in a similar way, and a tracker script is loaded indirectly using document.write(). Which script are you missing?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:rhandalthor
ID: 24077670
slider.js I guess as I want a similar slideshow on my website....
How do load others indirectly using document.write() ?
0
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 24078209
The slideshow seems to be defined here:

http://www.leemunroe.com/wp-content/themes/leemunroe/scripts.js

>> How do load others indirectly using document.write() ?

The google analytics tracker is loaded like this:

document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
0
 

Author Comment

by:rhandalthor
ID: 24078264
I see CXR. Well then the question remains why my slides don't show at http://lab.imagewize.net/doede/ . I load all script necessary I think, but I don't see slides being loaded. Please have a look and help me on my way. I am not very familiar with Javascript. Maybe I need to add st to the html or css to load it all?
0
 

Author Comment

by:rhandalthor
ID: 24078280
Think I found it.... Hold on
0
 

Author Comment

by:rhandalthor
ID: 24078379
Well one is visible. But there is not sliding yet... Any ideas why?
0
 

Author Comment

by:rhandalthor
ID: 24078714
Well added one more script and now it works. I only still get an empty background. That should not happen..
0
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 1500 total points
ID: 24078832
You have a javascript error:

uncaught exception: script.aculo.us requires the Prototype JavaScript framework >= 1.6.0.3

You must load the prototype file before the scriptaculous file.

The slideshow defined here: http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.2/slider.js
...is not the same as this: http://www.leemunroe.com/wp-content/themes/leemunroe/scripts.js

Your markup is prepared for the script from leemunroe.com, but you include the slider.js from scriptaculous.
0
 

Author Comment

by:rhandalthor
ID: 24079394
Added the missing slider.js from ajax.googleapis.... Working now. Also placed prototype above scriptaculous. All working now! :-) Thanks!
0
 

Author Comment

by:rhandalthor
ID: 24079449
slideshow.js is a a different script from slider.js. Named the former like that. I belive it is needed to run the slideshow besides effects.js and slider.js, scriptaculous and protoype..
0
 

Author Comment

by:rhandalthor
ID: 24086645
Well I experimented with some java scripts as I want the gallery to work with multibox. Multibox and NextGen Gallery did not work so I tried lightbox. No success. Went back to old settings. Now jquery is loaded. I don't no why. And I think it slows down the slideshow on the front page as it starts later.
0
 

Author Comment

by:rhandalthor
ID: 24086678
Well my favorite galery plugin NextGen gallery loads thickbox and jquery. When I turn of effects both scripts are droppped. But still the slider on the front page starts empty. How can I fix that?
0
 

Author Comment

by:rhandalthor
ID: 24086965
Well I fixed the empty space at startup. Now I need multibox to work on the portfollio page. It does not... yet.
0
 
LVL 39

Expert Comment

by:Roger Baklund
ID: 24087336
I have answered your original question and several follow-up questions allready. Please ask a new question.
0
 

Author Comment

by:rhandalthor
ID: 24087350
Sure. Will do that.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question